Ionic 3 app Build Failed for Android 12

Hi!, I have this problem.
trying to compile my app for android 12, I’m facing this error:

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 <activity>  |  Android Developers for details.

however, my AndroidManifest.xml looks fine I think:

<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="61" android:versionName="0.0.61" package="io.ionic.appsindicato" xmlns:android="http://schemas.android.com/apk/res/android">
    <supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
    <uses-permission android:name="android.permission.INTERNET" />
    <application android:exported="true" android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:usesCleartextTraffic="true">
        <activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:exported="true" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:screenOrientation="portrait" android:theme="@style/Theme.AppCompat.NoActionBar" android:windowSoftInputMode="adjustResize">
            <intent-filter android:label="@string/launcher_name">
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="org.apache.cordova.camera.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/camera_provider_paths" />
        </provider>
        <provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="de.appplant.cordova.emailcomposer.Provider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/emailcomposer_provider_paths" />
        </provider>
        <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
        <uses-library android:name="org.apache.http.legacy" android:required="false" />
        <receiver android:enabled="true" android:exported="false" android:name="nl.xservices.plugins.ShareChooserPendingIntent">
            <intent-filter>
                <action android:exported="false" android:name="android.intent.action.SEND" />
            </intent-filter>
        </receiver>
        <provider android:authorities="${applicationId}.sharing.provider" android:exported="false" android:grantUriPermissions="true" android:name="nl.xservices.plugins.FileProvider">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/sharing_paths" />
        </provider>
        <service android:exported="false" android:name="com.onesignal.ADMMessageHandler" />
    </application>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-feature android:name="android.hardware.location.gps" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-feature android:glEsVersion="0x00020000" android:required="true" />
    <uses-feature android:name="android.hardware.location" />
    <uses-permission android:name="android.permission.CALL_PHONE" />
    <uses-feature android:name="android.hardware.telephony" android:required="false" />
    <uses-permission android:name="com.amazon.device.messaging.permission.RECEIVE" />
    <permission android:name="io.ionic.appsindicato.permission.RECEIVE_ADM_MESSAGE" android:protectionLevel="signature" />
    <uses-permission android:name="io.ionic.appsindicato.permission.RECEIVE_ADM_MESSAGE" />
</manifest>

where do i have the problem?

I appreciate your help

Best Rgs.

have you upgraded your app libraries to the latest versions?

I facing the same error with platform 10.1.2 and also with platform 11.0.0 (API level 31).

how can I solve that? please help

upgrading your ionic 3 app to ionic 6 and capacitor 4 will solve for sure your problem.
It’s hard to understand what’s going on, please send a copy of your ionic info output

Instead of checking the actual AndroidManifest.xml file, check the “merged manifest” tab that appears on Android Studio when opening the file.

That will probably show other intent filters or activities plugins might be adding in their libraries that you won’t see in the regular AndroidManifest.xml.
It will also tell you which library is adding the intent filter or activity and that should help you which plugin is out of date.

Always make the build from command line, not on Android Studio

ionic cordova build android --release

and then run the command:

gradlew bundle

At what point should I open the project in android studio?

Thank you!

Ionic:

   Ionic CLI          : 6.18.1 (C:\tools\nvm\v12.13.0\node_modules\@ionic\cli)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.1

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : not available
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 2.5.3, (and 21 other plugins)

Utility:

   cordova-res : 0.15.4
   native-run  : 1.5.0

System:

   Android SDK Tools : 26.1.1 (c:\Users\Usuario\AppData\Local\Android\Sdk)
   NodeJS            : v12.13.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.12.0
   OS                : Windows 10

you can open it at any point, just because cordova prefers that you use the command line for everything doesn’t mean you can’t open the project in Android Studio

ok my friend,… i’m trying this.

Cordova CLI : 9.0.0, try upgrading to 11

Hello @derman10, I had the same problem.

First you need to know which Cordova plugin is causing it.

You need to go to the platforms/android/app/src/main/AndroidManifest.xml and searched for all <intent-filter> tags.

Then check if their parent tag has the android:exported property and add it where it is missing by using <edit-config>.

In my case, the Social Sharing plugin was causing the problem, so I add this in my config.xml file.

<platform name="android">
  <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/receiver[@android:name='nl.xservices.plugins.ShareChooserPendingIntent']">
    <activity android:exported="true" />
  </edit-config>
  ...
</platform>