Getting android:exported error even if it exists in AndroidManifest.xml

After I installed cordova-plugin-x-socialsharing plugin into my ionic cordova project I am getting the below error when executed build command:

> Task :app:processDebugMainManifest FAILED
D:\Project\@Codes Repos\Ionic6-cordova\platforms\android\app\src\main\AndroidManifest.xml 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 for details.

See for more information about the manifest merger.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> 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 for details.

If I check my AndroidManifest.xml file, the activity tag already has the android:exported="true" property.


<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="1" android:versionName="0.0.1" package="com.test.testproj" xmlns: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:networkSecurityConfig="@xml/network_security_config" android:supportsRtl="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: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" />
        <provider android:authorities="${applicationId}.fileOpener2.provider" android:exported="false" android:grantUriPermissions="true" android:name="io.github.pwlin.cordova.plugins.fileopener2.FileProvider">
            <meta-data android:name="" android:resource="@xml/opener_paths" />
        <receiver android:enabled="true" android:name="nl.xservices.plugins.ShareChooserPendingIntent">
                <action android:name="android.intent.action.SEND" />
        <provider android:authorities="${applicationId}.sharing.provider" android:exported="false" android:grantUriPermissions="true" android:name="nl.xservices.plugins.FileProvider">
            <meta-data android:name="" android:resource="@xml/sharing_paths" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <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" android:required="true" />
    <uses-permission android:name="android.permission.BLUETOOTH" />

Do I have to add the android:exported somewhere else as well?

Ionic Info


   Ionic CLI                     : 6.19.0 (C:\Users\CGauns\AppData\Roaming\nvm\v16.15.0\node_modules\@ionic\cli)
   Ionic Framework               : @ionic/angular 6.1.5
   @angular-devkit/build-angular : 13.2.6
   @angular-devkit/schematics    : 13.2.6
   @angular/cli                  : 13.2.6
   @ionic/angular-toolkit        : 6.1.0


   Cordova CLI       : 11.0.0
   Cordova Platforms : android 10.1.2
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 22 other plugins)


   cordova-res                          : 0.15.4
   native-run (update available: 1.6.0) : 1.5.0


   Android SDK Tools : 26.1.1 (D:\Android\sdk)
   NodeJS            : v16.15.0 (C:\Program Files\nodejs\node.exe)
   npm               : 8.5.5
   OS                : Windows 10

Screenshot from 2022-06-25 14-52-19
I’m facing the same issue, did you find any solution yet?

hi @syndeveloper I used older version of cordova-plugin-x-socialsharing and not the latest one.

I used version 5.3.1 as this was working on my ionic 3 app.

Please note that I was getting error while building and not while uploading the APK.

1 Like

@CGauns oh that fixed the problem?
currently i am using “cordova-plugin-x-socialsharing” spec=“^5.6.2”
should i have to update it ?

Using version 5.3.1, I was able to build and run the app. Also the sharing works. But haven’t tried uploading the app on Play store or App store.

@CGauns thank you! are you using android sdk 30+ ?

I have set target sdk as 31.

1 Like

Until the plugin author makes the necessary change, you can modify the file “plugin.xml” under /node_modules/cordova-plugin-x-socialsharing and add the android:exported=“true” there so that each time you compile, the generated manifest file for this plugin gets it:


@vorkapps thank you, but we do build our project on
so we won’t be having control over the manifest file :frowning:

hi @vorkapps ,

I did the change you have suggested but I am getting the same error

I checked the AndroidManifest.xml file under \platforms\android\app\src\main folder, android:exported="true" was not added. I had tried removing and adding platform.

hi @CGauns ,

You mentioned \platforms\android\app\src\main folder, which suggests you are not using Capacitor, so I’m not sure if my suggestion still holds, I would guess it should, as I am using Capacitor.

I checked my config.xml again, and there is another section that I had added the android:exported=“true” setting, and it’s this one: (maybe this is what made the effect)

edit: I was going to delete this reply, as I now see it’s irrelevant to the issue… Maybe the difference is the fact that I’m using Capacitor, and something else needs to be done for cordova scenarios… Sorry I couldn’t help further…


1 Like

hi @vorkapps

Your answer might not be related to Cordova, but it works.

I am not sure how it is working in Capacitor, but in Cordova, a separate folder called plugins is created in the root directory. In my case, the plugin configuration were picked from that folder. After setting the same properties in plugins\cordova-plugin-x-socialsharing\plugin.xml file, the issue got resolved.

Thank you for the help. :innocent: :+1:


You marked your reply as the solution, instead of my post providing the solution :slightly_smiling_face:

1 Like