Fatal Exception: java.lang.SecurityException One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified

I updated my app to API 34 but an exception occurs for some of the users as “java.lang.SecurityException” When I search for it I found that Since Android 14 there is a requirement to specify the export flag when registering context-registered receivers as written here

Well I am confused that when I only change to API to 33 there is no problem in my published app. But With API 34 something is needed on the KODULAR I think. Is there anyone understand this problem?

1 Like

You found out yourself, that there are also behavioral changes to consider… only changing the target api level in the manifest is not sufficient

See also Google play error: To release an update to your app, update the target API level by August 31, 2024 - #11 by Taifun

Which extensions aand components are you using? One of them needs an update

Taifun

1 Like

Extentions I used as below;
Two of them yours actually :slight_smile: Taifun Battery Optimization and TaifunFile
but I think the problem is related with ASDDownloader by @bodymindpower but I changed it with another ASDDownloader written by @The_K_Studio but problem on the google console I keep getting errors like below:

de.bodymindpower.DownloadToASD.DownloadToASD.
java.lang.SecurityException

OR

com.thekstudio.asddownloader.ASDDownloader.
java.lang.SecurityException

What you think? Can it be the problem or something else? Thank you for your kind reply by the way…

@bodymindpower and @The_K_Studio might want to check

Taifun

I will look into this. Meanwhile can you provide more information with respect to the error message, screenshots etc.

see here https://developer.android.com/about/versions/14/behavior-changes-14#runtime-receivers-exported

Runtime-registered broadcasts receivers must specify export behavior

Apps and services that target Android 14 (API level 34) or higher and use context-registered receivers are required to specify a flag to indicate whether or not the receiver should be exported to all other apps on the device: either RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED, respectively. This requirement helps protect apps from security vulnerabilities by leveraging the features for these receivers introduced in Android 13.

Taifun

1 Like

Can’t provide a bug report but in some phones it gives this error message after installing from google play in starting “Something went wrong with APP. APP closed because this app has a bug. Try updating this app after its developer provides a fix for this error” and immediately closes the app. But all I do it was in manifest file I manually changed the API version to 34. But when I downgrade it to API 33 everything works fine. On the console I see the error related to your extension is below:

com.thekstudio.asddownloader.ASDDownloader.
java.lang.SecurityException

I assume that some flag or permission for WRITE needs to be changed according to API 34 as google wants in your extension. Maybe lang related exception or something?

Taifun

We need to declare the flag in manifest file, is there a way to do it from extension itself, without manually editing the manifest file?

BroadcastReceiver receiver = new BroadcastReceiver.Builder(context, MyReceiver.class)
.setExported(exported)
.build();
// Register the receiver here

This code snippet from ChatGPT doesn’t work.

@The_K_Studio

1 Like

Thanks for the help @vknow360

I have tried to fix the error, anyone with API 34 and Android 14 device can test below aix:
ASDDownloaderTestVersionForAPI34.aix (35.2 KB)

an Android 14 device is not required to test this, only a builder which targets sdk 34, which is for example available here https://ai2-test.appinventor.mit.edu/

Taifun

1 Like

I tried your last version (number 6 I think) I want to publish as a beta. But google play console says this:

One problem has been detected
We’ve spotted some common issues that prevent your app from being submitted for review. Please resolve these issues before submitting your changes for review.
Technical quality
The broadcast receiver is registered incorrectly
Applications targeting Android version 13 or later must specify export behavior when registerReceiver() is executed. If the export behavior is not specified, your application may crash.

Your app targets Android version 13 or later and registers non-system broadcast receivers without specifying export behavior in the following places:

com.thekstudio.asddownloader.ASDDownloader

Please update your application to specify export behavior for registered broadcast receivers.

Ignore the aix which I previously sent.

Try this one, this should work:

Well I downgrade my app because I want lots of my users to use it! I think nobody really know that to do about their working apps at API 33 without problems. So what is it now?

I am seeing like these errors everywhere :
“Fatal Exception: 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”

I think google wants us a big think that couldn’t everyone to handle. Because I can not evet publish a new beta version for try, google refuses it because of the same issue… But all the codes are same, everything is same… But I am asking from all. What should we be do?

Read again this

And wait, until affected components and extensions have been upgraded for sdk 34 use

Did you already try the latest update from here? Fatal Exception: java.lang.SecurityException One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified - #17 by The_K_Studio

Taifun

I started a beta test with your extension mentioned here. But I figured out that only changing manifest to API34 is useless. Then I used Enhancer given here Enhancer : A powerful tool to change API level, inject assets, dex, manifest, resources & native (.so) libraries and sign the APK
But this doesn’t work. Google sees it as targeted SDK is API33 even I did all the things written in Enhancer. So I did a different thing. After using enhancer, I decompiled the apk with apkeasytool. Although after decompilng it shows as API34. I manually opened the manifest file and changed small things related to my app usage and recompiled it agin with apkeasy. After that I send the file to my phone and used APK to AAB converter but this time I used different keystore file and build the AAB. Then I send it to google then booom. It says your app is OK now, it is API 34! But I don’t know if it really worked. I am waiting for the bug reports from the different kinds of anroid phones to say that this work like a charm. But I want to thank you again for the effort to help me. I ıhope everthings gonna be fine :slight_smile:

edit: 1 bug report came now:
Exception java.lang.RuntimeException: Error while disconnecting UiAutomation@34526e8[id=-1, displayId=0, flags=0]
at android.app.UiAutomation.disconnect (UiAutomation.java:451)
at android.app.Instrumentation.finish (Instrumentation.java:272)
at androidx.test.runner.MonitoringInstrumentation.finish (MonitoringInstrumentation.java:9)
at androidx.test.runner.AndroidJUnitRunner.onStart (AndroidJUnitRunner.java:20)
at android.app.Instrumentation$InstrumentationThread.run (Instrumentation.java:2402)
Caused by android.os.DeadObjectException:
at android.os.BinderProxy.transactNative
at android.os.BinderProxy.transact (BinderProxy.java:584)
at android.app.IUiAutomationConnection$Stub$Proxy.disconnect (IUiAutomationConnection.java:471)
at android.app.UiAutomation.disconnect (UiAutomation.java:449)

I don’t know what is wrong but I think this is not extension related thing…

I hope my extension related functions are working properly.