google-analytics-plugin icon indicating copy to clipboard operation
google-analytics-plugin copied to clipboard

Plugging getting error for Android 12 due to :capacitor-cordova-android-plugins:processReleaseManifest execution failed

Open raulnsuarez opened this issue 2 years ago • 4 comments

Hello, I'm working on Ionic Framework using Capacitor. When I try to perform the assembleRelease the build process gets stopped by a failure in the :capacitor-cordova-android-plugins:processReleaseManifest task:

Task :capacitor-cordova-android-plugins:processReleaseManifest FAILED C:\Users\rsuarez\source\repos\Incentive\android\capacitor-cordova-android-plugins\src\main\AndroidManifest.xml:6:1-10:12 Error: android:exported needs to be explicitly specified for element <receiver#com.google.android.gms.analytics.AnalyticsReceiver>. 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 https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

See http://g.co/androidstudio/manifest-merger for more information about the manifest merger.

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':capacitor-cordova-android-plugins:processReleaseManifest'.

A failure occurred while executing com.android.build.gradle.tasks.ProcessLibraryManifest$ProcessLibWorkAction Manifest merger failed : android:exported needs to be explicitly specified for element <receiver#com.google.android.gms.analytics.AnalyticsReceiver>. 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 https://developer.android.com/guide/topics/manifest/activity-element#exported for details.


I set the "android:export=false" statement in the receiver index inside the AndroidManifest and the build process finally succeeds. The real issue is when I try to update the web assets to the Android project using "npx cap copy" the AndroidManifest is reset. I found a way to avoid this issue by updating manually the plugin.xml file in your module and adding the "android:exported" to the receiver key. Anyway, this fixes my local environment but I'm using Ionic's AppFlow to Release the App to the Play Store and the build process is fully automatic, so the manual update of the plugin.xml is not an alternative. I would like to evaluate this solution if it's possible, and if it's right and makes sense, create a fix for this. Of course, I'm not an expert and maybe this can't be performed the way I think, If this is the case, please can you tell me a way to win this situation? Thanks

raulnsuarez avatar Apr 19 '23 18:04 raulnsuarez

I am also facing the same error while trying to create APK. I tried your solution but it did not work for me at all.

hamza-mubeen-07 avatar Apr 20 '23 10:04 hamza-mubeen-07

If manipulate the plugin.xml doesn't work for you, you can manually update the AndroidManifest.xml file in android\capacitor-cordova-android-plugins\src\main and define android:exported=false in the receiver key, at least this works for me. Here it's what its looks like for me: image

I am also facing the same error while trying to create APK. I tried your solution but it did not work for me at all.

raulnsuarez avatar Apr 20 '23 14:04 raulnsuarez

Thanks this worked for me.

hamza-mubeen-07 avatar Apr 26 '23 10:04 hamza-mubeen-07

It looks like someone updated this 6 months ago, but there has not been a package update since the change was made. Can you please publish the project with a new version?

addahlbe avatar May 24 '23 15:05 addahlbe