square / react-native-square-reader-sdk

React Native Plugin for Square Reader SDK

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to resume activity - java.lang.SecurityException: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

fobos531 opened this issue · comments

Describe the issue

When trying to open Reader settings on React Native 0.73, I get this:

FATAL EXCEPTION: main
                                                                                                    Process: com.uxdotapp.pureshop, PID: 10667
                                                                                                    java.lang.RuntimeException: Unable to resume activity {com.uxdotapp.pureshop/com.squareup.ui.main.ApiMainActivity}: java.lang.SecurityException: com.uxdotapp.pureshop: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
                                                                                                    	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4962)
                                                                                                    	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4995)
                                                                                                    	at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:57)
                                                                                                    	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:180)
                                                                                                    	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98)
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443)
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:205)
                                                                                                    	at android.os.Looper.loop(Looper.java:294)
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8177)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
                                                                                                    Caused by: java.lang.SecurityException: com.uxdotapp.pureshop: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
                                                                                                    	at android.os.Parcel.createExceptionOrNull(Parcel.java:3057)
                                                                                                    	at android.os.Parcel.createException(Parcel.java:3041)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:3024)
                                                                                                    	at android.os.Parcel.readException(Parcel.java:2966)
                                                                                                    	at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:5684)
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method)
                                                                                                    	at shadow.leakcanary.ServiceWatcher$install$4$2.invoke(ServiceWatcher.kt:93)
                                                                                                    	at java.lang.reflect.Proxy.invoke(Proxy.java:1006)
                                                                                                    	at $Proxy7.registerReceiverWithFeature(Unknown Source)
                                                                                                    	at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1852)
                                                                                                    	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1792)
                                                                                                    	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1780)
                                                                                                    	at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:755)
                                                                                                    	at com.squareup.ui.MediaButtonDisabler.onResume(MediaButtonDisabler.java:38)
                                                                                                    	at com.squareup.ui.SquareActivity.onResume(SquareActivity.java:470)
                                                                                                    	at com.squareup.ui.main.MainActivity.onResume(MainActivity.java:205)
                                                                                                    	at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1603)
                                                                                                    	at android.app.Activity.performResume(Activity.java:8743)
                                                                                                    	at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4952)
                                                                                                    	at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4995) 
                                                                                                    	at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:57) 
                                                                                                    	at android.app.servertransaction.ActivityTransactionItem.execute(ActivityTransactionItem.java:45) 
                                                                                                    	at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:180) 
                                                                                                    	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:98) 
                                                                                                    	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2443) 
                                                                                                    	at android.os.Handler.dispatchMessage(Handler.java:106) 
                                                                                                    	at android.os.Looper.loopOnce(Looper.java:205) 
                                                                                                    	at android.os.Looper.loop(Looper.java:294) 
                                                                                                    	at android.app.ActivityThread.main(ActivityThread.java:8177) 
                                                                                                    	at java.lang.reflect.Method.invoke(Native Method) 
                                                                                                    	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) 
                                                                                                    	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971) 
                                                                                                    Caused by: android.os.RemoteException: Remote stack trace:

To Reproduce

Initialize an empty project.
Add Reader SDK.
Authorize with Reader SDK.
Try to open Reader Settings.

Expected behavior

I should see reader settings normally.

Environment (please complete the following information):

  • platform: Android
  • version: Android 14
  • environment - macOS
  • Reader SDK version: 1.4.3

@fka3 I believe this is an issue upstream in Square's implementation. Can this be fixed upstream? I would very much like to target SDK 34.

Hello!
Thank you, we confirmed that this crash is happening when targetSdkVersion=34 and device is running Android 14 (api 34).
We’re currently working on a proper fix in Reader SDK library, but don’t have an ETA on when it will be ready.
Meanwhile you can use following workaround to fix the issue:

In your custom Application class - the one that calls ReaderSdk.initialize(this) - add following

  @Override
  public Intent registerReceiver(@Nullable BroadcastReceiver receiver, IntentFilter filter) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU
        && receiver != null
        && receiver.getClass().getName().startsWith("com.squareup.")) {
      // Hotfix for Reader SDK not working on Android 14. Always use RECEIVER_EXPORTED.
      return super.registerReceiver(receiver, filter, RECEIVER_EXPORTED);
    } else {
      return super.registerReceiver(receiver, filter);
    }
  }