. Advertisement .
..3..
. Advertisement .
..4..
While developing any android application, at some point or the other we might come across an error ‘android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify’. Here are some tips to help developers fix the error.
How To Fix The Error “android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify”
Did you recently upgrade your emulator and Android SDK, and now you are unable to run your simple hello world project and keep receiving the following error?
***Manifest merger failed: Apps targeting Android 12 and higher are required to specify an explicit value for `android: exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.***
Simply specify android:exported=”false” or android:exported=”true” to fix this issue and operate your apps on Android 12. In addition, your manifest will appear as follows.
Option 1: Specify android:exported=”false” or android:exported=”true” in androidmenifest
Simply specify android:exported=”false” or android:exported=”true” to operate your apps on Android 12. In addition, your manifest will appear as follows:
<activity android:name=".MainActivity" android:exported="true" android:theme="@style/Theme.MyApplication.NoActionBar"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
Option 2: Set the sdk target to 30.
- Set the sdk target for 30 minutes first.
- After which, in the merged manifest, look for any activities, services, receivers, or providers that don’t have an exported set target sdk for 31.
- Override all of the entries you’ve discovered in the same way:
<receiver android:name="<name_of_the_entry>" android:exported="false or true" tools:node="merge" />
Option 3: Include androidx.test.ext:junit
In the compose.ui dependencies, try including androidx.test.ext:junit.
androidTestImplementation "androidx.test.ext:junit:1.1.3" androidTestImplementation "androidx.compose.ui:ui-test-junit4:1.0.4"
Conclusion
We hope you found our blog post on how to fix the problem “android:exported needs to be explicitly specified for . Apps targeting Android 12 and higher are required to specify” useful. If you have any other questions or concerns about this issue, please leave a comment. Thank you for taking the time to read; we are always thrilled when one of our posts can provide useful knowledge on this subject!
Leave a comment