androidflutterstartup

Fix for java.lang.SecurityException: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver... in Flutter (Android)


Problem

I got the following error when trying to start a flutter sample app, in my case the flutter gallery, on an Android device:

E/AndroidRuntime(20352): FATAL EXCEPTION: SplitCompatBackgroundThread
E/AndroidRuntime(20352): Process: io.flutter.demo.gallery, PID: 20352
E/AndroidRuntime(20352): java.lang.SecurityException: io.flutter.demo.gallery: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
E/AndroidRuntime(20352):        at android.os.Parcel.createExceptionOrNull(Parcel.java:3069)
E/AndroidRuntime(20352):        at android.os.Parcel.createException(Parcel.java:3053)
E/AndroidRuntime(20352):        at android.os.Parcel.readException(Parcel.java:3036)
E/AndroidRuntime(20352):        at android.os.Parcel.readException(Parcel.java:2978)
E/AndroidRuntime(20352):        at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:6157)
E/AndroidRuntime(20352):        at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1913)
E/AndroidRuntime(20352):        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1853)
E/AndroidRuntime(20352):        at android.app.ContextImpl.registerReceiver(ContextImpl.java:1841)
E/AndroidRuntime(20352):        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:772)
E/AndroidRuntime(20352):        at com.google.android.play.core.listener.b.b(Unknown Source:27)
E/AndroidRuntime(20352):        at com.google.android.play.core.listener.b.e(Unknown Source:3)
E/AndroidRuntime(20352):        at com.google.android.play.core.splitcompat.m.run(Unknown Source:7)
(More stacktrace here)

I expected the app to launch, as it would on Windows, but it didn't.


Solution

  • Solution

    I solved the problem by removing the following line (85 in my case) from android/app/build.gradle:

    implementation "com.google.android.play:core:1.10.0"

    And changing the following line (line 8 in my case) from android/app/src/main/AndroidManifest.xml: android:name="io.flutter.embedding.android.FlutterPlayStoreSplitApplication" To: android:name="${applicationName}"

    This does remove the Play Store functionality (not sure what it is exactly), but that isn't an issue in my case since I just wanted a sample app.