Search code examples
androidfluttercrashgoogle-playflutter-dependencies

The app crashes during the SMS auto-verify call on Android 14 when I change the targetSdkVersion to 34


The app crashes during the SMS auto-verify call on Android 14 when I change the targetSdkVersion to 34. I want to change it to 34 to upload it to the play console.

Error logs:

FATAL EXCEPTION: main E/AndroidRuntime(19989): Process: com.namp.zeon, PID: 19989 E/AndroidRuntime(19989): java.lang.SecurityException: com.namp.zeon: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts E/AndroidRuntime(19989): at android.os.Parcel.createExceptionOrNull(Parcel.java:3087) E/AndroidRuntime(19989): at android.os.Parcel.createException(Parcel.java:3071) E/AndroidRuntime(19989): at android.os.Parcel.readException(Parcel.java:3054) E/AndroidRuntime(19989): at android.os.Parcel.readException(Parcel.java:2996) E/AndroidRuntime(19989): at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:5684) E/AndroidRuntime(19989): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1868) E/AndroidRuntime(19989): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1804) E/AndroidRuntime(19989): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1792) E/AndroidRuntime(19989): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:765) E/AndroidRuntime(19989): at com.jaumard.smsautofill.SmsAutoFillPlugin$2.onSuccess(Unknown Source:44) E/AndroidRuntime(19989): at com.jaumard.smsautofill.SmsAutoFillPlugin$2.onSuccess(Unknown Source:2) E/AndroidRuntime(19989): at com.google.android.gms.tasks.zzm.run(Unknown Source:25) E/AndroidRuntime(19989): at android.os.Handler.handleCallback(Handler.java:958) E/AndroidRuntime(19989): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(19989): at android.os.Looper.loopOnce(Looper.java:257) E/AndroidRuntime(19989): at android.os.Looper.loop(Looper.java:368) E/AndroidRuntime(19989): at android.app.ActivityThread.main(ActivityThread.java:8839) E/AndroidRuntime(19989): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(19989): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:572) E/AndroidRuntime(19989): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1049) E/AndroidRuntime(19989): Caused by: android.os.RemoteException: Remote stack trace: E/AndroidRuntime(19989): at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:14900) E/AndroidRuntime(19989): at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570) E/AndroidRuntime(19989): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3005) E/AndroidRuntime(19989): at android.os.Binder.execTransactInternal(Binder.java:1387) E/AndroidRuntime(19989): at android.os.Binder.execTransact(Binder.java:1299) E/AndroidRuntime(19989):

Steps to reproduce Change the targetSdkVersion in build.gradle to 34.

use this plugin(sms_autofill: ^2.3.0) for sms auto fill.

Expected results It should fetch the OTP code from the message.

Actual results App crashes when moving to the verify otp screen.


Solution

  • you need to explicitly add the android:exported attribute in your AndroidManifest.xml for the BroadcastReceiver.

      <receiver
        android:name=".YourReceiver"
        android:exported="false">
        <intent-filter>
            <action android:name="com.example.MY_ACTION" />
        </intent-filter>
      </receiver>
    

    Or update

    from (sms_autofill: ^2.3.0) to (sms_autofill: ^2.4.0)