Applications targeting Android 12 and higher are required to specify an explicit value for `android:exported`

139 Views Asked by At
> Task :app:processDebugAndroidTestManifest FAILED
C:\Users\Prajwal\AndroidStudioProjects\Kotlin_basics\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest8532940286002594.xml Error:
    android:exported needs to be explicitly specified for <activity>. 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.
C:\Users\Prajwal\AndroidStudioProjects\Kotlin_basics\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest8532940286002594.xml Error:
    android:exported needs to be explicitly specified for <activity>. 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.
C:\Users\Prajwal\AndroidStudioProjects\Kotlin_basics\app\build\intermediates\tmp\manifest\androidTest\debug\tempFile1ProcessTestManifest8532940286002594.xml Error:
    android:exported needs to be explicitly specified for <activity>. 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.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.


Execution failed for task ':app:processDebugAndroidTestManifest'.
> Manifest merger failed with multiple errors, see logs

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

I began my coding experience with Kotlin basics and have been encountering manifest errors. Please assist. This is a silly and straightforward question.

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.kotlin_basics">

    <application
        android:exported="true"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.Kotlin_basics" />
    
</manifest>

This is my current full manifest I don't have a Main activity recorded..

2

There are 2 best solutions below

0
Waseem Abbas On

Starting from Android 12 (API level 31), you are required to specify an explicit value for the android:exported attribute in your AndroidManifest.xml file for all components (activities, services, broadcast receivers, and content providers) that can be accessed by other apps.

You should explicitly specify whether a component can be accessed by other apps or not by setting the android:exported attribute to either true or false. Here's how you can do it for different components:

<activity
    android:name=".YourActivity"
    android:exported="true">
</activity>

Set android:exported to true if you want other apps to be able to start this activity otherwise false.

<service
    android:name=".YourService"
    android:exported="true">
    <!-- Other service attributes -->
</service>

You need to add this attribute to all of your activities, services, broadcast receivers, and content providers.

0
Sarah On

Main Activity, that is, if you change exported to true for the first application to run when the app is launched, it will be solved.

Open the AndroidManifest.xml file and set export to true, like the blue highlight in the screenshot below.

android:exported="true"

enter image description here

Please refer to the relevant document below.

https://developer.android.com/topic/security/risks/android-exported

Good Luck.