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

[Android 14] Crash Exception - RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED is required #670

Closed
MateoParodi opened this issue Jun 26, 2023 · 26 comments
Labels
bug Something isn't working

Comments

@MateoParodi
Copy link

MateoParodi commented Jun 26, 2023

Hello everyone!

Since last week, we updated our android sdk to 34, to support Android 14, and we are getting some crashes on firebase:

Fatal Exception: java.lang.SecurityException: com.my-test-app.app: 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:5668) 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.android.billingclient.api.zzh.zzc(com.android.billingclient:billing@@4.1.0:1) at com.android.billingclient.api.zzi.zze(com.android.billingclient:billing@@4.1.0:1) at com.android.billingclient.api.BillingClientImpl.startConnection(com.android.billingclient:billing@@4.1.0:36) at com.revenuecat.purchases.google.BillingWrapper.startConnection(BillingWrapper.kt:120) at com.revenuecat.purchases.google.BillingWrapper.startConnectionOnMainThread$lambda-3(BillingWrapper.kt:106) at com.revenuecat.purchases.google.BillingWrapper.$r8$lambda$hLiSTu2HCHKyRrb-HVFlJFdt_lQ() at com.revenuecat.purchases.google.BillingWrapper$$ExternalSyntheticLambda9.run(:2) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:205) at android.os.Looper.loop(Looper.java:294) at android.app.ActivityThread.main(ActivityThread.java:8176) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Any ideas on what could be happening? (usefull link maybe)

@MateoParodi MateoParodi added the bug Something isn't working label Jun 26, 2023
@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@tonidero
Copy link
Contributor

Hi @MateoParodi, thanks for reaching out!

Yes, we're able to reproduce this issue, this is a known issue in the billing library from Google: https://github.com/android/play-billing-samples/issues/618.

As it says in that issue, Google released an update last week that fixes the issue. We are going to update our libraries to include that fix, so expect a new release very soon. We will update this issue once the SDK has been updated to that billing library version.

@tonidero
Copy link
Contributor

Hi @MateoParodi, we just released new versions of our SDKs including the fix in Google's billing library. Can you try version 6.2.1 of our react native SDK and let us know the results?

@MateoParodi
Copy link
Author

Nice! Thanks for the catch up!

We are currently using "react-native-purchases": "^5.13.2" so, if I bump to v6 Im forced to do the migration to the
New Google subscription model? or is not mandatory and I can still use the old subscription model?

@tonidero
Copy link
Contributor

Hi @MateoParodi,

Unfortunately, we can't release a v5 patch release with this change, since Google only released the fix with billing client 5 and 6, but not with 4, which is what RN v5 is pointing to.

v6 of the RN SDK does introduce support for the new Google subscription model. This means that you will start seeing non-backwards compatible products (if you have any) once you migrate. Having said that, if all the products you're using in the Play console are backwards compatible, you should need minimal to no changes. In any case, please let us know if you run into issues during this migration and we would be happy to help!

@MateoParodi
Copy link
Author

Hello again @tonidero,

Lucky for us, yes, all our products on Google Play are backwards compatible.

I updated to v6 and im already seeing that the response from Purchases.getOfferings() changed a lot.

In v5 we were able to get all the packages from the .availablePackages in the offering. from there we get the product and we know already if the product has an offer, for example I see the offer in the introPrice property.
but since v6, with the new payload with all this subscriptionOptions, all my products comes with introPrice: null, so how can I identify if a product has an introPrice now? we need that because we need to show it in the paywall.

@tonidero
Copy link
Contributor

Hi again @MateoParodi,

A few questions.

  • Are you using the StoreProduct's introPrice property? That should default to the defaultOption's introPrice which is calculated by us following this logic: https://www.revenuecat.com/docs/subscription-offers#google-play.
  • Is it possible the Google account you're using has already used the intro trial?
  • Does the StoreProduct you're using have a freeTrial? According to the logic we follow to calculate the defaultOption, that would take precedence over an introductory offer.
  • Could you try to iterate over the StoreProduct's subscriptionOptions list and see if one of them matches your expectations? If that's happening but it's not the defaultOption, that means the logic we are following does not match what you were expecting and would help us debug your issue.

@MateoParodi
Copy link
Author

Yes, my product has a freeTrial of 7 days.

  • Are you using the StoreProduct's introPrice property? YES.
  • Is it possible the Google account you're using has already used the intro trial? Yes, but before with the v5 I can always see the introPrice in the package despite the Google account I'm using already used the free trial.

I attach 2 screenshots:
The first one with the packages of the v5 response:
jsoncrack com (1)

And this one with the response of the v6. you can see that in the v6 I don't have anywhere the freeTrial of the package/product. Is this because im using a google account that already used the free trial? before it wasn't like that right?
jsoncrack com (3)

@MateoParodi
Copy link
Author

Alright, I have the answer, looks like now in the v6, in android at least, the introPrice comes only if the Google Account is eligible for it.

So that solves my questions.

Regarding the crashes, I'll do some testing and checking firebase after the release and I will post here so we can close the issue after.

Thank you very much for the support!

@MateoParodi
Copy link
Author

Hello again @tonidero

Im doing some tests here in the android emulator and I can see in the adb logcat that my app is crashing for the same reason:

E AndroidRuntime: Caused by: java.lang.SecurityException: com.my-test.app: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

Also, I see that you guys updated the billing library to 5.2.1, but the fix I think is in the 6.0.1
https://developer.android.com/google/play/billing/release-notes#6-0-1

See comment here: https://github.com/android/play-billing-samples/issues/618

@tonidero
Copy link
Contributor

Hi @MateoParodi,

Hmm that's strange... We were able to reproduce the issue and it got fixed after upgrading to 5.2.1. Also, Google's billing library 5.2.1 was released together with 6.0.1 with the same release notes.

Just to confirm, is this exception also coming from the billing client?

@MateoParodi
Copy link
Author

any ideas or help on how can I know if the exception is comming from the billing client? Im not seeing it in my logs

@tonidero
Copy link
Contributor

Are you able to see the full stack trace @MateoParodi? In your original stacktrace, it was clear that the issue was coming from the billing client: com.android.billingclient.api.zzh.zzc(com.android.billingclient:billing@@4.1.0:1) at .

Another way to confirm whether this comes from the RevenueCat SDK (more concretely from the billing client we depend on), is to put some breakpoints/prints before/after the SDK is configured and make sure the crash is happening there.

@MateoParodi
Copy link
Author

hI @tonidero, Im pretty sure the crash is still coming from RC.

I have the version 6.2.2 and if I comment everything related to react-native-purchases on the javascript side, the crash disappears and the app builds and runs normally.
As soon as I try to fetch the offerings for example, the crash is happening.

Im testing on the emulator Pixel_4_API_34(AVD) - Android 14 with --mode release

@tonidero
Copy link
Contributor

Hi @MateoParodi I tried our sample app:

  • With the 6.2.2 SDK
  • Changing the target and compile android versions to 34
  • On an Android 34 emulator
  • In release mode
    I was able to fetch offerings and purchase fine.

I did run into issues in debug mode, where it was crashing with this stacktrace:

Caused by: java.lang.SecurityException: com.revenuecat.purchases_sample: 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:5668)
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.facebook.react.devsupport.DevSupportManagerBase.reload(DevSupportManagerBase.java:1101)
at com.facebook.react.devsupport.DevSupportManagerBase.reloadSettings(DevSupportManagerBase.java:721)
at com.facebook.react.devsupport.DevSupportManagerBase.setDevSupportEnabled(DevSupportManagerBase.java:593)
at com.facebook.react.devsupport.DevSupportManagerBase.<init>(DevSupportManagerBase.java:206)
at com.facebook.react.devsupport.BridgeDevSupportManager.<init>(BridgeDevSupportManager.java:78)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at com.facebook.react.devsupport.DefaultDevSupportManagerFactory.create(DefaultDevSupportManagerFactory.java:86)
at com.facebook.react.ReactInstanceManager.<init>(ReactInstanceManager.java:255)
at com.facebook.react.ReactInstanceManagerBuilder.build(ReactInstanceManagerBuilder.java:330)
at com.facebook.react.ReactNativeHost.createReactInstanceManager(ReactNativeHost.java:94)
at com.facebook.react.ReactNativeHost.getReactInstanceManager(ReactNativeHost.java:41)
at com.revenuecat.purchases_sample.MainApplication.onCreate(MainApplication.java:60)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6997)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2236)
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:8176)
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)

In this case, it would seem that react-native debug systems are crashing in Android 14, but it seems unrelated to RevenueCat. Also, seems like this might be an issue in react native: facebook/react-native#37769

One thought that comes to mind, do you maybe have cached an older version of the SDK? Still trying to figure out if there is something else wrong.

@ThushalIntervest
Copy link

Hi, @tonidero did you find any fix for this RN issue?

@tonidero
Copy link
Contributor

Hi @ThushalIntervest, I haven't tried it recently, but looks like RN released 0.72.4 last week which seems to have included the fix. Have you tried that out?

@ThushalIntervest
Copy link

ThushalIntervest commented Aug 22, 2023

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 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 android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1852) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1792) at android.app.ContextImpl.registerReceiver(ContextImpl.java:1780)

Yes, I upgraded new RN version. still occurred this issue. 😔

@tonidero
Copy link
Contributor

I suggest asking in the RN issue then (I see you already did). I will retry this myself when I have time but this issue doesn't seem related to RevenueCat. I'm going to close this issue since the original issue seems to have been fixed.

@ThushalIntervest
Copy link

@tonidero I just figured this happen because I used react-native-blob-util library. They did not add a fix for that. Sorry for my misunderstood.

@ZouZLong
Copy link

@ThushalIntervest I also encountered the same problem, how did you solve it?

@Prathap38
Copy link

Add ContextCompat.registerReceiver( this, mMessageReceiver, filter, ContextCompat.RECEIVER_EXPORTED )

@GSSPawanKumarSingh
Copy link

@ThushalIntervest I also encountered the same problem, while saving a file to a device how did you solve it?

@ZouZLong
Copy link

ZouZLong commented Feb 24, 2024 via email

@shayanfarshad
Copy link

Add ContextCompat.registerReceiver( this, mMessageReceiver, filter, ContextCompat.RECEIVER_EXPORTED )

where should we add this line ?

@ZouZLong
Copy link

ZouZLong commented May 22, 2024 via email

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

8 participants