flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
164.77k stars 27.16k forks source link

W/FlutterEngine(30444): Tried to automatically register plugins with FlutterEngine (io.flutter.embedding.engine.FlutterEngine@7a0372e) but could not find and invoke the GeneratedPluginRegistrant. #65261

Closed CaLouro closed 3 years ago

CaLouro commented 4 years ago

Hello everyone.

I've been getting this error on flutter console and I don't know what it means or implies, and I'd like some help.

W/FlutterEngine(30444): Tried to automatically register plugins with FlutterEngine (io.flutter.embedding.engine.FlutterEngine@7a0372e) but could not find and invoke the GeneratedPluginRegistrant.

This error doesn't show 100% of the time, but it's very frequent. Additionally I've been getting errors on Firebase Installations API and I thought this could be the reason.

I thank any help on this problem.

Logs ``` flutter analyze Analyzing ... No issues found! (ran in 29.0s) ``` ``` flutter doctor -v [✓] Flutter (Channel stable, 1.20.3, on Microsoft Windows [versão 10.0.19041.450], locale pt-BR) • Flutter version 1.20.3 at C:\Users\caios\Documents\flutter • Framework revision 216dee60c0 (3 days ago), 2020-09-01 12:24:47 -0700 • Engine revision d1bc06f032 • Dart version 2.9.2 [✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3) • Android SDK at C:\Users\caios\AppData\Local\Android\sdk • Platform android-29, build-tools 29.0.3 • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) • All Android licenses accepted. [✓] Android Studio (version 4.0) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin version 48.1.2 • Dart plugin version 193.7547 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) [✓] VS Code (version 1.48.2) • VS Code at C:\Users\caios\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.14.0 [✓] Connected device (1 available) • SM G965U1 (mobile) • 35494b4435563098 • android-arm64 • Android 10 (API 29) • No issues found! ```
iapicca commented 4 years ago

@CaLouro if the problem is with firebase the issue should be opened here

CaLouro commented 4 years ago

Hey @iapicca I don't think the problem is with Firebase. For me it looks like an error with Flutter Engine that errors a Firebase API

But thanks for reminding me of the flutterfire repo, I'll see if something like this was posted there

TahaTesser commented 4 years ago

Hi @CaLouro Can you please check your gradle version is 3.5.0 in your build.gradle in the flutter app -> Android Makes sure it is classpath 'com.android.tools.build:gradle:3.5.0 and not higher Reference

If the problem persists, Can you please provide your build.gradle, your MainActivity, your flutter run --verboze, your pubspec.yaml Thank you

CaLouro commented 4 years ago

Hi @TahaTesser, checking what you asked for:

Project level build.gradle ```gradle buildscript { ext.kotlin_version = '1.3.50' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.3' classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.0' } } allprojects { repositories { google() jcenter() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" } subprojects { project.evaluationDependsOn(':app') } task clean(type: Delete) { delete rootProject.buildDir } ```
My unchanged MainActivity.kt ```kotlin package com.gmail.dev.caiolouro.boi_na_balanca import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() { } ```
pubspec.yaml ```yaml name: boi_na_balanca description: The project for the Boi na Balaça Android app. # The following line prevents the package from being accidentally published to # pub.dev using `pub publish`. This is preferred for private packages. publish_to: 'none' # Remove this line if you wish to publish to pub.dev # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 # followed by an optional build number separated by a +. # Both the version and the builder number may be overridden in flutter # build by specifying --build-name and --build-number, respectively. # In Android, build-name is used as versionName while build-number used as versionCode. # Read more about Android versioning at https://developer.android.com/studio/publish/versioning # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html version: 0.1.0+5 environment: sdk: ">=2.9.0 <3.0.0" dependencies: flutter: sdk: flutter # Firebase packages firebase_core: ^0.5.0 cloud_firestore: ^0.14.0+2 firebase_analytics: ^6.0.0 firebase_crashlytics: ^0.2.0-dev.5 firebase_auth: ^0.18.0+1 # google_sign_in: # State and management packages flutter_modular: mobx: flutter_mobx: # Internationalization and formatting intl: date_format: currency_textfield: # Interface helpers admob_flutter: ^1.0.0-beta.5 # flutter_auth_buttons: flutter_form_builder: ^3.13.0 # Mock packages # cloud_firestore_mocks: dev_dependencies: flutter_test: sdk: flutter # Generated code build_runner: ^1.10.1 mobx_codegen: modular_codegen: # Launcher helpers flutter_launcher_name: flutter_launcher_icons: # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec # The following section is specific to Flutter. flutter: # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true assets: - assets/logos/logo2-transp.png # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware. # For details regarding adding assets from package dependencies, see # https://flutter.dev/assets-and-images/#from-packages # To add custom fonts to your application, add a fonts section here, # in this "flutter" section. Each entry in this list should have a # "family" key with the font family name, and a "fonts" key with a # list giving the asset and other descriptors for the font. For # example: # fonts: # - family: Schyler # fonts: # - asset: fonts/Schyler-Regular.ttf # - asset: fonts/Schyler-Italic.ttf # style: italic # - family: Trajan Pro # fonts: # - asset: fonts/TrajanPro.ttf # - asset: fonts/TrajanPro_Bold.ttf # weight: 700 # # For details regarding fonts from package dependencies, # see https://flutter.dev/custom-fonts/#from-packages flutter_launcher_name: name: "Boi na Balança" flutter_icons: ios: false android: true image_path: "assets/logos/logo2-circ.png" adaptive_icon_background: "#4CAF50" adaptive_icon_foreground: "assets/logos/logo2-transp.png" ```

I was trying to reproduce the error, but I couldn't, it doesn't show every time, so I'm not including the flutter run -v log, sorry. If I eventually can, I'll sent it.

Thanks for all the help.

TahaTesser commented 4 years ago

Hi @CaLouro You can manually register plugins with FlutterEngine with the following

class MainActivity: FlutterActivity() {

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        GeneratedPluginRegistrant.registerWith(flutterEngine)
    }
}

If the problem still persists using this, please provide complete logs Thank you

CaLouro commented 4 years ago

@TahaTesser I've added this code piece you suggested but I got the following error

Launching lib\main.dart on SM G965U1 in debug mode...
Running Gradle task 'assembleDebug'...
e: C:\Users\caios\Desktop\boi_na_balanca\android\app\src\main\kotlin\com\gmail\dev\caiolouro\boi_na_balanca\MainActivity.kt: (7, 5): 'configureFlutterEngine' overrides nothing
e: C:\Users\caios\Desktop\boi_na_balanca\android\app\src\main\kotlin\com\gmail\dev\caiolouro\boi_na_balanca\MainActivity.kt: (7, 56): Unresolved reference: FlutterEngine

FAILURE: Build failed with an exception.

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

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8s
Exception: Gradle task assembleDebug failed with exit code 1

My MainActivity.kt at the time was

package com.gmail.dev.caiolouro.boi_na_balanca

import io.flutter.embedding.android.FlutterActivity
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterActivity() {
    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        GeneratedPluginRegistrant.registerWith(flutterEngine)
    }
}

flutter doctor -v

[√] Flutter (Channel stable, 1.20.3, on Microsoft Windows [versão
    10.0.19041.450], locale pt-BR)
    • Flutter version 1.20.3 at C:\Users\caios\Documents\flutter
    • Framework revision 216dee60c0 (7 days ago), 2020-09-01 12:24:47 -0700
    • Engine revision d1bc06f032
    • Dart version 2.9.2

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
    • Android SDK at C:\Users\caios\AppData\Local\Android\sdk
    • Platform android-29, build-tools 29.0.3
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
    • All Android licenses accepted.

[√] Android Studio (version 4.0)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 49.0.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)

[√] VS Code (version 1.48.2)
    • VS Code at C:\Users\caios\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.14.0

[√] Connected device (1 available)
    • SM G965U1 (mobile) • 35494b4435563098 • android-arm64 • Android 10 (API 29)

• No issues found!
TahaTesser commented 4 years ago

@CaLouro

Make sure you've imported flutterEngine Open your Android folder in Android Studio, you will see missing import errors

import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugins.GeneratedPluginRegistrant

class MainActivity: FlutterActivity() {

    override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
        super.configureFlutterEngine(flutterEngine)
        GeneratedPluginRegistrant.registerWith(flutterEngine)
    }

}
logs ``` Running "flutter pub get" in stable_flutter... Launching lib/main.dart on RMX2001 in debug mode... ✓ Built build/app/outputs/flutter-apk/app-debug.apk. Installing build/app/outputs/flutter-apk/app.apk... Connecting to VM Service at ws://127.0.0.1:51208/YUeTq0cX0_0=/ws I/GED (28741): ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 27, oppidx_max 27, oppidx_min 0 I/.stable_flutte(28741): ProcessProfilingInfo new_methods=430 is saved saved_to_disk=1 resolve_classes_delay=5000 I/SurfaceView(28741): 30673836 visibleChanged:true -> SurfaceHolder.Callback.surfaceDestroyed D/Surface (28741): Surface::disconnect(this=0x7685ff5000,api=1) D/ViewRootImpl(28741): setSurfaceViewCreated, created:false D/Surface (28741): Surface::disconnect(this=0x7685ff5000,api=-1) D/SurfaceView(28741): updateScreenMode w:0 h:0 ViewRoot w:1080 h:2400 D/SurfaceView(28741): try to resquest 90Hz D/ViewRootImpl(28741): set screen refresh mode 0 due to SurfaceView-30673836 I/Choreographer(28741): Skipped 3 frames! The application may be doing too much work on its main thread. I/GED (28741): ged_boost_gpu_freq, level 100, eOrigin 2, final_idx 27, oppidx_max 27, oppidx_min 0 D/Surface (28741): Surface::disconnect(this=0x7685ff3000,api=1) V/PhoneWindow(28741): DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@323255f, this = DecorView@636f780[MainActivity] V/PhoneWindow(28741): DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@323255f, this = DecorView@636f780[MainActivity] D/Surface (28741): Surface::connect(this=0x771c2ba000,api=1) D/mali_winsys(28741): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000 D/Surface (28741): Surface::setBufferCount(this=0x771c2ba000,bufferCount=4) I/SurfaceView(28741): 30673836 visibleChanged:true -> SurfaceHolder.Callback.surfaceCreated D/Surface (28741): Surface::connect(this=0x7685b1f000,api=1) D/mali_winsys(28741): EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000 D/ViewRootImpl(28741): setSurfaceViewCreated, created:true I/SurfaceView(28741): 30673836 surfaceChanged -- format=4 w=1080 h=2400 visibleChanged:true -> SurfaceHolder.Callback.surfaceChanged D/SurfaceView(28741): updateScreenMode w:1080 h:2400 ViewRoot w:1080 h:2400 D/SurfaceView(28741): try to resquest 60Hz D/ViewRootImpl(28741): set screen refresh mode 1 due to SurfaceView-30673836 D/SurfaceView(28741): updateScreenMode w:1080 h:2400 ViewRoot w:1080 h:2400 D/SurfaceView(28741): try to resquest 60Hz I/Choreographer(28741): Skipped 2 frames! The application may be doing too much work on its main thread. ```
flutter doctor -v ``` [✓] Flutter (Channel stable, 1.20.3, on Mac OS X 10.15.6 19G2021, locale en-GB) • Flutter version 1.20.3 at /Users/tahatesser/Code/flutter_stable • Framework revision 216dee60c0 (8 days ago), 2020-09-01 12:24:47 -0700 • Engine revision d1bc06f032 • Dart version 2.9.2 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/tahatesser/Code/sdk • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /Users/tahatesser/Code/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 11.7) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.7, Build version 11E801a • CocoaPods version 1.9.3 [✓] Android Studio (version 4.0) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 49.0.2 • Dart plugin version 193.7547 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) [✓] VS Code (version 1.48.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.14.1 [!] Connected device ! No devices available ! Doctor found issues in 1 category. ```
CaLouro commented 4 years ago

@TahaTesser Made my MainActivity.kt exactly like yours and this error showed up and the app crashed at launch.

Launching lib\main.dart on SM G965U1 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build\app\outputs\flutter-apk\app-debug.apk.
W/FlutterEnginePluginRegistry(10329): Attempted to register plugin (io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry$ShimRegistrarAggregate@99db182) but it was already registered with this FlutterEngine (io.flutter.embedding.engine.FlutterEngine@c66093).
E/AndroidRuntime(10329): FATAL EXCEPTION: main
E/AndroidRuntime(10329): Process: com.gmail.dev.caiolouro.boi_na_balanca, PID: 10329
E/AndroidRuntime(10329): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.gmail.dev.caiolouro.boi_na_balanca/com.gmail.dev.caiolouro.boi_na_balanca.MainActivity}: java.lang.IllegalStateException: registrar.context() must not be null
E/AndroidRuntime(10329):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3632)
E/AndroidRuntime(10329):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3784)
E/AndroidRuntime(10329):    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
E/AndroidRuntime(10329):    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
E/AndroidRuntime(10329):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
E/AndroidRuntime(10329):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2270)
E/AndroidRuntime(10329):    at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime(10329):    at android.os.Looper.loop(Looper.java:237)
E/AndroidRuntime(10329):    at android.app.ActivityThread.main(ActivityThread.java:8125)
E/AndroidRuntime(10329):    at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(10329):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
E/AndroidRuntime(10329):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1100)
E/AndroidRuntime(10329): Caused by: java.lang.IllegalStateException: registrar.context() must not be null
E/AndroidRuntime(10329):    at com.shatsy.admobflutter.AdmobFlutterPlugin$Companion.registerWith(AdmobFlutterPlugin.kt:32)
E/AndroidRuntime(10329):    at com.shatsy.admobflutter.AdmobFlutterPlugin.registerWith(Unknown Source:2)
E/AndroidRuntime(10329):    at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:18)
E/AndroidRuntime(10329):    at com.gmail.dev.caiolouro.boi_na_balanca.MainActivity.configureFlutterEngine(MainActivity.kt:11)
E/AndroidRuntime(10329):    at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:180)
E/AndroidRuntime(10329):    at io.flutter.embedding.android.FlutterActivity.onCreate(FlutterActivity.java:411)
E/AndroidRuntime(10329):    at android.app.Activity.performCreate(Activity.java:7957)
E/AndroidRuntime(10329):    at android.app.Activity.performCreate(Activity.java:7946)
E/AndroidRuntime(10329):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
E/AndroidRuntime(10329):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3607)
E/AndroidRuntime(10329):    ... 11 more
Waiting for SM G965U1 to report its views...
Debug service listening on ws://127.0.0.1:52934/dZRdLonfa6M=/ws
Syncing files to device SM G965U1...
I/Process (10329): Sending signal. PID: 10329 SIG: 9
TahaTesser commented 4 years ago

Hi @CaLouro Can you please a different device or emulator?

CaLouro commented 4 years ago

@TahaTesser ok, tested the main activity like you suggested plus I ran flutter clean before the test.

This time I tested on an emulator (before I was using a real device) and the app still crashes and I get this error

Launching lib\main.dart on sdk gphone x86 in debug mode...
Running Gradle task 'assembleDebug'...
✓ Built build\app\outputs\flutter-apk\app-debug.apk.
Installing build\app\outputs\flutter-apk\app.apk...
W/FlutterEnginePluginRegistry( 9107): Attempted to register plugin (io.flutter.embedding.engine.plugins.shim.ShimPluginRegistry$ShimRegistrarAggregate@719ddfd) but it was already registered with this FlutterEngine (io.flutter.embedding.engine.FlutterEngine@654caf2).
Waiting for sdk gphone x86 to report its views...
Debug service listening on ws://127.0.0.1:63464/SjpzMupP2dU=/ws
Syncing files to device sdk gphone x86...
I/Process ( 9107): Sending signal. PID: 9107 SIG: 9
Lost connection to device.
Could not update files on device: HttpException: Connection closed before full header was received, uri = http://127.0.0.1:63464/SjpzMupP2dU=/
TahaTesser commented 4 years ago

Hi @CaLouro Can you please do me favor and remove futterfire and comment out its code and try again You can remove configure engine code and make sure this in your AndroidManifest.xml

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}
    <application
        android:name="io.flutter.app.FlutterApplication"
        android:label="plugin_error"
        android:icon="@mipmap/ic_launcher">
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

https://github.com/flutter/flutter/issues/65525 had a similar issue, this fixed the issue https://github.com/flutter/flutter/issues/65525#issuecomment-690093089

CaLouro commented 3 years ago

Hey @TahaTesser, sorry for the long wait.

I haven't seen this error in a while and the errors with flutterfire dropped significantly. I think the problem was with the gradle version and sdk versions that I kept updating without reason.

I'll close this issue for now too.

Thanks for everything and take care.

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.