tonyofrancis / Fetch

The best file downloader library for Android
https://www.meta.stackoverflow.com/tags/fetch2
Apache License 2.0
1.66k stars 343 forks source link

registerReciever method exception android 14 for flag RECEIVER_EXPORTED #680

Open sharif-ahmed opened 4 months ago

sharif-ahmed commented 4 months ago

context.registerReceiver(priorityBackoffResetReceiver, IntentFilter(ACTION_QUEUE_BACKOFF_RESET))

ghost commented 3 months ago

where should be use this context.registerReceiver(priorityBackoffResetReceiver, IntentFilter(ACTION_QUEUE_BACKOFF_RESET)) and on which version?

hammadbawara commented 2 months ago

How did you fix your issue? I am getting this broadcast error when I targetSdk to >= 33 error

RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

Full Error Log

FATAL EXCEPTION: main
                                                                                                    Process: com.example.download_testing, PID: 4096
                                                                                                    java.lang.RuntimeException: Unable to create application com.example.download_testing.MyApp: java.lang.SecurityException: com.example.download_testing: 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.handleBindApplication(ActivityThread.java:7003)
                                                                                                        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: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.example.download_testing: 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)
                                                                                                        at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:755)
                                                                                                        at com.tonyodev.fetch2.helper.PriorityListProcessorImpl.<init>(PriorityListProcessorImpl.kt:71)
                                                                                                        at com.tonyodev.fetch2.fetch.FetchModulesBuilder$Modules.<init>(FetchModulesBuilder.kt:125)
                                                                                                        at com.tonyodev.fetch2.fetch.FetchModulesBuilder.buildModulesFromPrefs(FetchModulesBuilder.kt:53)
                                                                                                        at com.tonyodev.fetch2.Fetch$Impl.getInstance(Fetch.kt:1026)
                                                                                                        at com.example.download_testing.MyApp.onCreate(MyApp.kt:44)
                                                                                                        at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1316)
                                                                                                        at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6998)
                                                                                                        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: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:
                                                                                                        at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:13927)
                                                                                                        at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2570)
                                                                                                        at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2720)
                                                                                                        at android.os.Binder.execTransactInternal(Binder.java:1339)
                                                                                                        at android.os.Binder.execTransact(Binder.java:1275)
devpascoe commented 2 months ago

Same @hammadbawara, any luck?

hammadbawara commented 2 months ago

@devpascoe There are some fixes available in the pull requests, but they haven't been merged yet. You can use that code and compile it yourself. Since this library hasn't been maintained for 4 years, it may cause more issues in the future, which is why I switched to another library.