Abdullah Ziauddin
Abdullah Ziauddin

Reputation: 139

Manifest merger failed : Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported`

Please help me with this error getting in my project while trying to run at mobile via android studio.

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.

Upvotes: 11

Views: 29385

Answers (9)

Benard Agustin
Benard Agustin

Reputation: 79

if you just add local notification package, and that error appear try to make your

android/app/src/main/AndroidManifest.xml to look like

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.environmental">
   <application
        android:usesCleartextTraffic="true"
        android:label="environmental"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
   

 <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize"
        android:exported="true"
       
        >
      

  <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
            
        </activity>
       

        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />

            <!-- malicer -->
      <receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ActionBroadcastReceiver" />
        <receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationReceiver" />
        <receiver android:exported="false" android:name="com.dexterous.flutterlocalnotifications.ScheduledNotificationBootReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED"/>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED"/>
                <action android:name="android.intent.action.QUICKBOOT_POWERON" />
                <action android:name="com.htc.intent.action.QUICKBOOT_POWERON"/>
            </intent-filter>
        </receiver>
        <!-- malicer -->
    </application>
    
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
    <!-- malicer -->
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
    <uses-permission android:name="android.permission.VIBRATE" />
    <uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT" />
    <uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM" />
    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
    <!-- malicer -->
</manifest>

add those line which are absent in your file, then run

flutter clean and then flutter build

NOTE: This is based much for problem caused by flutter_local_notification package

am using flutter_local_notifications: ^8.2.0

Upvotes: 1

Syed Danial
Syed Danial

Reputation: 655

I had to add android:exported="true"

In all the tags where intent-filter was present For me they were

receiver service activity

I faced this issue while upgrading my React Native app to v12. as I was facing a crash upon receiving the notification.

Upvotes: 0

AIMIN PAN
AIMIN PAN

Reputation: 1675

Add this to your manifest to the activity tag in the error message:

android:exported="true"

This happens when your activity can be started by another application. For example image viewer can be started by file manager when clicking an image. The image viewer app is "exported".

It's also always required if you are using the following code necessary for dynamic links:

    <intent-filter>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent-filter>

Example:

    <activity
        android:name=".MainActivity"
        android:launchMode="singleTop"
        android:theme="@style/LaunchTheme"
        android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
        android:hardwareAccelerated="true"
        android:windowSoftInputMode="adjustResize"
        android:exported="true">
       
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>

Upvotes: 14

Adesipe Adeola
Adesipe Adeola

Reputation: 151

Add android:exported="true" into the Manifest file inside of the application activity

<application
    <activity
        android:exported="true"
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/Theme.NoteKeeper.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

Upvotes: 1

Akash p
Akash p

Reputation: 67

This is for the projects using Bootsplash. My project used Bootsplash and I solved it by adding android:exported="true" also to the activity of Bootsplash in the AndroidManifest file.

<application
  <activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
    android:launchMode="singleTask"
    android:windowSoftInputMode="adjustPan"
    android:exported="true"                   // <----ADD THIS
    android:screenOrientation="portrait">
    
  </activity>
   <activity
    android:name="com.zoontek.rnbootsplash.RNBootSplashActivity"
    android:theme="@style/BootTheme"
    android:exported="true"                    // <----ADD THIS
    android:launchMode="singleTask">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
  </activity>
</application>

Upvotes: 1

ladytoky0
ladytoky0

Reputation: 679

I found this solution!!.

So you have to add the android:exported="true" into the activity tag in the manifest (not in the application).

<application
        android:fullBackupContent="@xml/my_backup_rules"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name">
        <activity android:name=".yourActivity" android:exported="true">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".otherActivity" android:exported="true"/>

    </application>

To see more information about the exported property, see App manifest file activity

:)

Upvotes: 7

Amer Al zibak
Amer Al zibak

Reputation: 1951

if you are using flutter ,may some deprecated lib in your ap is causing this .. for me: upgrading flutter_local_notifications to the latest version (now is 9.3.2) solved this error..

Upvotes: 3

Praj
Praj

Reputation: 704

You had to figure out the component missing the Android exported tag. You should downgrade your SDK version and check the final merged manifest file for the components missing the exported tag but has IntentFilter.

The step-by-step instructions is provided in this link.

Upvotes: 2

Hardik Hirpara
Hardik Hirpara

Reputation: 3046

If you have any activity, service, receiver, or provider that does not have exported set in your manifest file then add whenever it needed like,

android:exported="false or true"

Upvotes: 2

Related Questions