duplicate element declared at AndroidManifest.xml - cordova build android
See original GitHub issueIssue Type
- Bug Report
- Feature Request
- [x ] Support Question
Trying to migrate the project to android 12. sdk 31. When executing “cordova prepare android” , receiving the error Element receiver#com.google.android.gms.analytics.AnalyticsReceiver at AndroidManifest.xml:53:9-57:20 duplicated with element declared at AndroidManifest.xml
Information
noticed that the issue started with adding android:export=“true/false” attribute, which is required for android 12 to activity/reciever/service.
Command or Code
cordova prepare android / merger manifest adds duplicate tags, tools: replace=“android:exported” does not works
Environment, Platform, Device
Version information
cordova -vesion : 11.0.0 Cordova Platform : android 9.0.0 cordova plugins : cordova-plugin-3dtouch 1.3.8 “3D Touch” cordova-plugin-actionsheet 2.3.3 “ActionSheet” cordova-plugin-add-swift-support 2.0.2 “AddSwiftSupport” cordova-plugin-app-launcher 0.4.0 “Launcher” cordova-plugin-app-review 2.0.3 “AppReviewPlugin” cordova-plugin-app-version 0.1.9 “AppVersion” cordova-plugin-calendar 5.1.5 “Calendar” cordova-plugin-customurlscheme 4.4.0 “Custom URL scheme” cordova-plugin-device-name 1.3.5 “Device-Name” cordova-plugin-device 1.1.7 “Device” cordova-plugin-dialogs 1.3.4 “Notification” cordova-plugin-exit 1.0.3 “Exit” cordova-plugin-fingerprint-aio 3.0.0 “FingerprintAllInOne” cordova-plugin-firebase-analytics 0.14.0 “FirebaseAnalyticsPlugin” cordova-plugin-foresee 2.0.0 “ForeSeeAPI” cordova-plugin-geolocation 4.0.2 “Geolocation” cordova-plugin-google-analytics 1.8.6 “Google Universal Analytics Plugin” cordova-plugin-inappbrowser 4.0.0 “InAppBrowser” cordova-plugin-queries-schemes 0.1.1 “App Queries Strings” cordova-plugin-screen-orientation 1.4.2 “Screen Orientation” cordova-plugin-secure-storage 3.0.2 “SecureStorage” cordova-plugin-shortcuts-android 0.1.0 “Android Shortcuts” cordova-plugin-sslcertificatechecker 5.1.0 “SSL Certificate Checker” cordova-plugin-statusbar 2.4.2 “StatusBar” cordova-plugin-whitelist 1.3.3 “Whitelist” cordova-support-android-plugin 1.0.2 “cordova-support-android-plugin” cordova-support-google-services 1.1.0 “cordova-support-google-services” phonegap-plugin-multidex 1.0.0 “Multidex” phonegap-plugin-push 2.2.3 “PushPlugin” uk.co.workingedge.phonegap.plugin.launchnavigator 5.0.6 “Launch Navigator”
Checklist
- [ x] I searched for already existing GitHub issues about this
- I updated all Cordova tooling to their most recent version
- [x ] I included all the necessary information above
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Related StackOverflow Question
Personally I fork and remove the entry in a plugin that is creating the duplication, just so it works for the app, which I know isn’t ideal, but tends to be the easiest path forward to get moving. The
<edit-config>is suppose to manage this to a degree, as well as conflicts, but it doesn’t work very well unfortunately. I think<config-file>always inserts the child regardless if a duplicate already exists, which might be the root of the issue if you have two plugins using the<config-file>directive to add the same thing. I’m not sure if<config-file>should blindly forbid/ignore duplicate tags though, I think perhaps it may need to be a configuration parameter, if that path is taken.I’ve been exploring different ways to improve management of these config files where multiple independent things may want to manipulate, but haven’t really found a “quick” solution to the problem that Cordova could implement. The duplication detection in
<config-file>however probably wouldn’t be too difficult to actually implement, if that is actually the source of the duplication problem.A hook script would probably work too as a workaround, and would avoid requiring to fork any plugin, but if multiple plugins are manipulating the manifest in hooks, you may run into conflict-like issues.
The
exportthing was patched in the latest patch of cordova-android@10, so that the Cordova Activity will have the exported attribute explicitly set in cordova-android@10.1.2 or later. If other plugins adds in additional activities/services, etc… they may still need to be updated to also explictly set the exported attribute as appropriate.Thank you everyone for all the help. I am able to resolve the issue by updating the cordova-android to 11. Apparently, I was also working on jdk8 which needs to be updated to jdk11.