SkyeBoniwell
SkyeBoniwell

Reputation: 7122

issue when importing library into Flutter

I downloaded a Flutter app from a git repository. It's a fairly simple app that I want to experiment with.

Anyway, I upgraded my versions of Android Studio, AndroidSDK, JDK, and flutter.

I also ran 'flutter doctor' and get no issues found.

Additionally, I ran 'flutter packages get' to make sure I had everything needed.

But when I try to use 'flutter run' to run the app, I get the following error:

e: G:\Code Projects and Solutions\Flutter\NotHotDog-master\android\app\src\main\kotlin\com\bimsina\nothotdog\MainActivity.kt: (6, 27): Unresolved reference: GeneratedPluginRegistrant
e: G:\Code Projects and Solutions\Flutter\NotHotDog-master\android\app\src\main\kotlin\com\bimsina\nothotdog\MainActivity.kt: (11, 5): Unresolved reference: GeneratedPluginRegistrant

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugKotlin'.
> Compilation error. See log for more details

When I navigate to the file with the errors, I see this:

package com.bimsina.nothotdog

import android.os.Bundle

import io.flutter.app.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterActivity() {
  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    GeneratedPluginRegistrant.registerWith(this)
  }
}

I'm pretty new with Flutter, so I'm not exactly sure what to do next. I've Googled it a ton, but can't really find anything specific.

Honestly I'm not sure if this is even a Flutter issue or an issue with java.

Has anyone ever seen anything like this before?

Thanks!

Upvotes: 1

Views: 4929

Answers (1)

janstol
janstol

Reputation: 3156

The GeneratedPluginRegistrant.java file in android\app\src\main\java\io\flutter\plugins is missing, which is strange because this file should be generated automatically. I managed to find the repo and I got the same error. It seems like the project is 'broken'...

I suggest you create a new flutter project and:

  • copy dart files from /lib folder and update imports
  • copy /assets folder
  • copy dependencies and assets: part (pubspec.yaml)
  • add Firebase dependencies to Gradle files and add googleServices.json

After that it should run.

Upvotes: 1

Related Questions