skip to Main Content

I am moving from SDK version 30 to 31 and I add android:exported in intent-filter but still I am getting this error:

Merging Errors: Error: android:exported needs to be explicitly specified for . 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.

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

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <application
        android:name=".App"
        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/AppTheme">
        <!-- Sample AdMob App ID: ca-app-pub-3940256099942544~3347511713 -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-3940256099942544~3347511713"/>

        <activity android:name="com.mycompany.webviewapp.SplashActivity"
            android:exported="true"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="com.mycompany.webviewapp.MainActivity"
            android:exported="true"
            android:screenOrientation="portrait">
            <intent-filter>
                <category android:name="android.intent.category.LAUNCHER"/>
                <action android:name="android.intent.action.VIEW"></action>
            </intent-filter>

        </activity>

        <service android:name="com.mycompany.webviewapp.FCM.MyFirebaseMessagingService">

        </service>

        <meta-data android:name="applovin.sdk.key"
            android:value="sdk api here"/>

    </application>

</manifest>

2

Answers


  1. Chosen as BEST ANSWER

    I resolve my issue. I just check the merged manifest and look for reciver. In onesignal, I found out reciver with intent filter defined without android:exported. I just add android:exported="false".


  2. The reason is because some of the dependency libraries that you’re using have elements which do not have "android:exported" attribute.

    You need to do this:

    • Lower the version in your gradle to 30 and sync and build.
    • Go to your AndroidManifest.xml file and click on "Merged Manifest".
    • Find items such as Activity, Receiver, Service, etc that don’t have "android:exported" attribute.
    • Then add them to your AndroidManifest.xml file in this way.
    <activity
        android:name="SomeActivity"
        android:exported="false"
        tools:node="merge"
        tools:replace="android:exported" />
    

    Now you can increase your version to 31.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search