-
Notifications
You must be signed in to change notification settings - Fork 786
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
RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED #866
Comments
i am also face this error any one solve this ????? |
Thi is related to Android SDK 34 where you must explicitly specify export behaviour for broadcasts. It was fixed in RN however this library doesn't seem to be updated. I've fixed it by updating it manually. You can try using this patch: diff --git a/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java b/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
index a8abd71..efa1b46 100644
--- a/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
+++ b/node_modules/rn-fetch-blob/android/src/main/java/com/RNFetchBlob/RNFetchBlobReq.java
@@ -196,7 +196,11 @@ public class RNFetchBlobReq extends BroadcastReceiver implements Runnable {
DownloadManager dm = (DownloadManager) appCtx.getSystemService(Context.DOWNLOAD_SERVICE);
downloadManagerId = dm.enqueue(req);
androidDownloadManagerTaskTable.put(taskId, Long.valueOf(downloadManagerId));
- appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
+ if (Build.VERSION.SDK_INT >= 34 && appCtx.getApplicationInfo().targetSdkVersion >= 34) {
+ appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE), Context.RECEIVER_EXPORTED);
+ }else{
+ appCtx.registerReceiver(this, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
+ }
return;
}
|
Thanks for the answer, that really helped !! |
Thanks for the answer, that helped me as well!! |
Yeah, it helps but now after downloading the file, my app crash |
it's working fine for me. |
Same, the file gets downloaded but right after that the app crashes with the same error One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts |
Did you find any solution? |
Due to lack of information and for quick need, i ditch using rn-fetch-blob and start using react-native-fs, and it's working perfectly |
I updated to 0.74.2 - now there is no red screen but the app is like close |
I have changed the tagetSDKVersion = 33 and it works for me |
@miradario thanks. I just seems finally was able to fix it. The advice maybe which can help. I chanage packages which was hardcode vesion. I mean for example "abc-package": "x.x.x" to"abc-package": "^x.x.x". Not sure it can help but maybe you can find this way the problem library. |
Yes, there's a lot of breakage in targetSDKVersion 34, it's good if we just rely on 33 |
From August 31 it is mandatory to update to latest version API level 34. This issue needs to fixed immediately :( Warning from google: |
We're still trying to figure out how to resolve the below issue, I've tried all the suggestions but still getting the below Error:
Can someone advise here as by Aug 31 we must add our apps with SDK 34. I've already tried the below with no success: in the MainActivity.java `@Override
}` Also tried to add the code into:
And change the below call: to: Also not works, Added the Implementations into the dependencies of build.gradle also not helped. The only thing succeeded is the failure of "classes2.dex' is not allowed." Which fixed in the MainActivity after super.onCreate(); by calling the below line Can someone advise here with more ideas? I'm still using "react-native": "0.64.3" and not sure I can do such movement now to new version. |
I think I've figure out the issue, Let me explain, In general the first part of the Exception is a Generic error and refers to the ReactNative module which contains the below call:
The best way to fix the issue, first search in your Exception which module is failing into, for example, in each Exception you will find "registerReceiver" and right after will be "onHostResume". In my exception it was referring to the below line So I've accessed "RNCAppearanceModule.java" file and somehow I saw that it contains old version of the register call as this module not updated frequently. Existing line: I've added change it with the below line (Added the 3rd parameter which is needed): Make sure "Context" is imported. Still you must get the below steps done to fix the issue:
import android.content.BroadcastReceiver;
Please add @ before Override and Nullable.
Please try and update if it'e working for you. Thanks All, My issue resolved finally! |
It didn't helped in my case |
Please share the exception to try understand what you're facing |
yeah It is solved, in my case, I have to change this line in react-native-orientation package to new line now it is resolved for me |
@rabiaah For me its working too. I just had to add We might need to wait for the libraries to update their calls to be fully compatible with the new API level requirements |
I don't use this library but still get the same error.
{ |
Thanks body. I have been looking for a solution since last week. |
It's related only for Android devices with SDK34, why you're sharing the full React code? |
Please share the solution to this issue. I am sharing my code because I have implemented every method I could think of to resolve it. |
Solution already shared, if you can share the full exception then only we might help as it's not related to react code. |
please pin the solution , Expectation is i just want to download the pdf in device , whenever i click on download button , my pdf file downloads but my app crash , |
Please share the exception what is not clear dear? Anyway, I have updated before the below solution, please review the posts here. |
I think this repository is no longer maintained by the maintainer.
Then, inside your
Once this is done, the code will be automatically modified after |
you could just use "patch-package" |
where do i make these changes?, what file? |
Detailed explanation and potential issue fixes are added and discussed in this Medium article: |
Thankyou @rabiaah , My issue is resolved |
@rabiaah Could you help me, I am receiving the same error as gourav3309 was. Here is the full Exception:
|
onHostResume(RNHeadphoneDetectionModule.java:151) Go to RNHeadphoneDetectionModule.java line 151. Search for activity.registerReceiver You need to add as 3rd parameter. Context.RECEIVER_EXPORTED Try and update. |
There were no results for the search activity.registerReceiver and according to the warnings I am receiving the problem is in RNHeadphoneDetectionModule.java in this function private void maybeRegisterReceiver() it shows a warning at this line:
Warning is: So I added it like so:
but then go this error: |
That's fine, it's the same just add the context to the call Like: reactContext.registerReceiver(receiver, new IntentFilter(BluetoothAdapter.EXTRA_STATE), Context.RECEIVER_EXPORTED); You may need to import Context if not imported already or use any available context inside the class. |
Please review my steps shared in the accepted comment, you need to update your gradle. |
I was able to debug this same error in my case with adb logcat and look the receiver errors to come up and noticed this orientation library coming up after the receiver errors:
Went to check for updates on this library called react-native-orientation-locker I was using and they indeed had an update to fix the issue. This is the file they updated just in case it helps someone: |
Thanks you, I've add your code into this lib, every body can using my lib already fixed: https://www.npmjs.com/package/rn-fetch-blob-repair?activeTab=readme |
In order for me to work I had to put this code on MainActivity and on MainApplication, My RN version is really old (0.63.2) still I was able to compile the app for Api 34, |
I follow this tuto and working |
Thankyou ji
…On Thu, 3 Oct, 2024, 8:06 pm Yuri Lima, ***@***.***> wrote:
I follow this tuto and working
***@***.***/fixing-broadcastreceiver-crashes-and-metro-server-issues-in-android-14-3b7d05939a43
—
Reply to this email directly, view it on GitHub
<#866 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BJRYWJNYAYBKWUPVD36OJ3LZZVJADAVCNFSM6AAAAABE6VDVP2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJRGU4DSMRXGY>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
hi, how did you put this code in MainActivity? |
I tried nearly everything, but ultimately, I had to remove the react-native-orientation library from my project, and now it’s working fine. |
Hi !
error One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
The text was updated successfully, but these errors were encountered: