基于Ionic+Cordova的Android项目提交.aab至Google Play控制台时遭遇Android 12的android:exported(<receiver>组件)错误求助
android:exported Error for Unlisted <receiver> in Ionic/Cordova Projects Hey there, let's get this sorted out! The issue you're facing is super common with Ionic/Cordova projects targeting Android 12+—that missing <receiver> component isn't from your local AndroidManifest.xml; it's being added by one of your Cordova plugins during the manifest merge process. Android 12+ requires every component with an intent filter (like receivers, activities, services) to explicitly declare the android:exported attribute, and some older plugins haven't updated their manifests to comply.
Here's how to fix it step by step:
1. Identify the problematic plugin
First, you need to find which plugin is injecting the unconfigured <receiver>:
- List all your installed plugins with:
cordova plugin list - Then, search for
<receiver>tags in the merged manifest directory (this will show you the full component details):- On Mac/Linux:
grep -r "<receiver" platforms/android - On Windows PowerShell:
Select-String -Path platforms/android/**/*.xml -Pattern "<receiver"
- On Mac/Linux:
Look for the receiver that doesn't have android:exported set—note its full android:name value and which plugin it belongs to.
2. Update the plugin (preferred fix)
Most popular plugins have already released updates to support Android 12+. Try updating the problematic plugin first:
cordova plugin update [plugin-name]
After updating, rebuild your project with ionic cordova build android --release and check if the error is gone.
3. Override the receiver's exported property in config.xml
If the plugin hasn't been updated (or the update doesn't fix it), you can force-set the android:exported attribute directly from your project's config.xml:
Add this block inside the <platform name="android"> section, replacing the android:name value with the receiver you found earlier:
<edit-config file="AndroidManifest.xml" target="/manifest/application/receiver[@android:name='com.your.problematic.receiver']" mode="merge"> <receiver android:exported="true" /> <!-- Use "false" if the receiver only works within your app --> </edit-config>
- Note: Choose
trueif the receiver needs to accept intents from outside your app (like system broadcasts),falseif it's only used internally.
4. Remove the plugin (if you don't need it)
If the plugin is unnecessary for your project, just remove it entirely:
cordova plugin remove [plugin-name]
Rebuild your project afterward to confirm the error disappears.
5. Verify the fix
After applying any of the above steps, clean your build cache first to avoid old artifacts:
cordova clean android
Then rebuild your project and check the merged manifest at platforms/android/app/build/intermediates/merged_manifests/release/AndroidManifest.xml—the problematic receiver should now have the android:exported attribute set.
内容的提问来源于stack exchange,提问作者Valmir Zunino Neto

