Crash: startActivity in Android API 34

712 views Asked by At

Does anyone know what this error means and what I can do about it:

*FATAL EXCEPTION: main

Process: com.familiekoning.radionedplus, PID: 3772 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.familiekoning.radionedplus/com.familiekoning.radionedplus.MainActivity}: java.lang.SecurityException: com.familiekoning.radionedplus: 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.performLaunchActivity(ActivityThread.java:3782)*

It happens with:

val intent = Intent(this, MainActivity::class.java)
startActivity(intent) //CRASH in Android 34

and only in Android API34

Also a crash when I make the intent explicit with the same error:

val explicitIntent = Intent(this, MainActivity::class.java)
explicitIntent.setPackage("com.familiekoning.radionedplus")
startActivity(explicitIntent) //CRASH in Android 34

Thanks for your help ;)

1

There are 1 answers

0
Jeff Bowman On BEST ANSWER

Resolved in the comments:

In MainActivity I indeed registered some receivers without a third parameter: RECEIVER_EXPORTED. I changed that and now it works fine.

As Yunus linked in the comments, this is one of the new security features for Android 14 (API level 34) as documented at https://developer.android.com/about/versions/14/behavior-changes-14 .