App keeps crashing after recent upgrade to new versions of Flutter( v1.12.13+hotfix.8) and other libraries

Viewed 1074

App is crashing with following error message in some devices. Its not happening in all devices.

Fatal Exception: java.lang.UnsupportedOperationException
The new embedding does not support the old FlutterView.
io.flutter.embedding.engine.plugins.shim.ShimRegistrar.view (ShimRegistrar.java:82)
io.flutter.plugins.camera.CameraPlugin.registerWith (CameraPlugin.java:54)
io.flutter.plugins.GeneratedPluginRegistrant.registerWith (GeneratedPluginRegistrant.java:47)
com.pickcel.taskmanagement.Application.registerWith (Application.java:22)
com.transistorsoft.flutter.backgroundgeolocation.HeadlessTask.startBackgroundIsolate (HeadlessTask.java:186)
com.transistorsoft.flutter.backgroundgeolocation.HeadlessTask.dispatch (HeadlessTask.java:94)
com.transistorsoft.flutter.backgroundgeolocation.HeadlessTask.run (HeadlessTask.java:88)

Device list :

  1. Xiaomi (Note 7 pro, poco f1, etc)
  2. Samsung (Galaxy M30, S10, A50)
  3. HMD Global (Nokia 4.2, 2.2),

** Mostly with Android OS - PIE(9)

It caused 6K+ crashes till now. I have check the project and i'm not using ShimRegistrar anywhere.

1 Answers

I was also receiving this very same (annoying) errors and also using the background_fetch plugin. Once my app was terminated it wasn't possible to make the background_fetch wake it up without trapping into a FATAL error.

It happens that this plugin was recently updated to a new V2 plugin API standard and it requires that many small changes are made in the "Android side" of your Flutter project.

I strongly recommend that you follow these instructions:

https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

After that please compare your AndroidManifest.xml, Application.java, MainActivity.java and styles.xml files with the ones available at:

https://github.com/transistorsoft/flutter_background_fetch/tree/master/example/android/app/src/main

My Flutter Doctor results in case you want to compare with yours.

[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.18363.720], locale en-US)
    • Flutter version 1.12.13+hotfix.8 at D:\Tools\flutter
    • Framework revision 0b8abb4724 (5 weeks ago), 2020-02-11 11:44:36 -0800
    • Engine revision e1e6ced81d
    • Dart version 2.7.0


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at D:\Android\android-sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = C:\Android\android-sdk
    • ANDROID_SDK_ROOT = C:\Android\android-sdk
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
    • All Android licenses accepted.

[√] Android Studio (version 3.6)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 44.0.2
    • Dart plugin version 192.7761
    • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] VS Code, 32-bit edition
    • VS Code at C:\Program Files (x86)\Microsoft VS Code
    • Flutter extension version 3.8.1

[√] VS Code, 64-bit edition (version 1.43.0)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.8.1
Related