'How to set Android exported for Cordova application

I am need to publish a Cordova application on Google Play targeting Android 12. When I uploaded my APK file, I get error

You uploaded an APK or Android App Bundle which has an activity, activity alias, service or broadcast receiver with intent filter, but without the 'android:exported' property set. This file can't be installed on Android 12 or higher. See: developer.android.com/about/versions/12/behavior-changes-12#exported

I did some reaserch on internet and I found, that this configuration should be add to config.xml:

    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
        <activity android:exported="true"/>
    </edit-config>  

It works fine for some of my applications, but one of them still shows the error, when uploaded to Google Play. Its AndroidManifest.xml looks like this:

<?xml version='1.0' encoding='utf-8'?>
  <manifest android:hardwareAccelerated="true" android:versionCode="750" android:versionName="7.5.0" package="cz.foxtrot.motoquest" 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: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="singleTask" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.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>
       <receiver android:enabled="true" android:name="nl.xservices.plugins.ShareChooserPendingIntent">
           <intent-filter>
               <action android:name="android.intent.action.SEND" />
           </intent-filter>
       </receiver>
       <provider android:authorities="${applicationId}.sharing.provider" android:exported="true" android:grantUriPermissions="true" android:name="nl.xservices.plugins.FileProvider">
           <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/sharing_paths" />
       </provider>
       <meta-data android:name="com.transistorsoft.locationmanager.license_key" android:value="b2c8e0bf1863da91b0f941ddf8278f699d320a320182cf7eb1d1e5c660ee17be" />
   </application>
   <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
   <uses-permission android:name="com.android.vending.BILLING" />
   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>

Any ideas, what can be wrong?



Solution 1:[1]

try adding this to your cordova config.xml under <platform name="android">:

<edit-config file="app/src/main/AndroidManifest.xml" target="/manifest/application/activity" mode="merge">
  <activity android:exported="true" />
</edit-config>
<edit-config file="app/src/main/AndroidManifest.xml" target="/manifest/application/service" mode="merge">
  <service android:exported="true" />
</edit-config>  

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1