Pendam

ShaileshPendam

Shailesh Pendam | Sr.Software Engineer

Uploaded an APK which has an activity, activity alias, service or broadcast receiver with intentfilter, but without 'android ':' exported' property set

Posted on November 30, 2022

by Shailesh Pendam

Modify AndroidManifest.xml in ionic project

According to google new policy If your app targets Android 12 or higher and contains activities, services, or broadcast receivers that use intent filters, you must explicitly declare the android:exported: true attribute for these app components.

You might ask when I need to add android:exported=“true” or android:exported=“false” to the activities, services, or broadcast receivers that use intent filters. If the app component includes the LAUNCHER category, set android: exported to true otherwise set android: exported to false.

In ionic we cant be directly modify AndroidManifest.xml file , Becuse for evrey build it its create new AndroidManifest tags

phonegap.push

in my case I have defined android: exported for each and every activity, service, or receiver in my main manifest file but in my project, I was using phonegap.push I found that there is an activity , services and receiver which are using property without android: exported so I am using cordova-custom-config plugin to solve this issue.

Steps

The plugin uses hook scripts to update iOS and Android platform configuration files based on custom data defined in config.xml. So we need to Install this Plugin first

Installation

The plugin is registered as cordova-custom-config on npm (requires Cordova CLI 5.0.0+)

 cordova plugin add cordova-custom-config

Or cordova@6.2+ if the —fetch option is specified explicitly:

cordova plugin add cordova-custom-config --fetch

NOTE: There are no run-time source files included in this plugin - it is simply a convenient package of hook scripts.

Removable preferences via backup/restore

By default, any changes made by this plugin to platform config files are irreversible - i.e. if you want to undo changes made by the plugin, you’ll need to remove then re-add the Cordova platform, for example:

 cordova platform rm android && cordova platform add android

However, if you want the changes made to be reversible, you can enable auto-backup/restore functionality by adding the following preference inside the top-level element of your config.xml:

Just check on Inside platforms/android/app/src/main/AndroidManifest.xml

AndroidManifest.xml copy plugin name from here name="android: and add on Config.XML

Example

Config.XML

 <platform name="android">
<custom-preference name="android-manifest/uses-permission/[@android:name='android.permission.com.adobe.phonegap.push.PushInstanceIDListenerService']" delete="true" />
</platform>

more information https://www.npmjs.com/package/cordova-custom-config