Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #226

Open
fobos531 opened this issue Jan 9, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@fobos531
Copy link
Contributor

fobos531 commented Jan 9, 2024

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
@fobos531 fobos531 added the bug Something isn't working label Jan 9, 2024
@fobos531
Copy link
Contributor Author

@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.

@Armaxis
Copy link
Member

Armaxis commented Feb 21, 2024

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);
    }
  }

@harshil-vyas08
Copy link

We are also facing the same issue in our custom Android application using Square Reader SDK API :14 & Target:34. Kindly do needful or any workaround because our square users are madly behind square products.

@fobos531
Copy link
Contributor Author

fobos531 commented Aug 9, 2024

Hello @harshil-vyas08

Square has just released 1.7.6 of Android SDK which should fix this https://developer.squareup.com/docs/changelog/mobile-logs/2024-08-07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants