duplicate element declared at AndroidManifest.xml - cordova build android

See original GitHub issue

Issue 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:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
breautekcommented, Nov 9, 2022

To add to this, what is the best practice to avoid duplications, if plugins are not maintained anymore… besides forking those and fixing the problem myself.

Using a script in a hook that “cleans up duplicates”… or what are people doing?

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.

noticed that the issue started with adding android:export=“true/false” attribute, which is required for android 12 to activity/reciever/service.

The export thing 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.

1reaction
nnaik1commented, Nov 9, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

duplicated with element declared at AndroidManifest.xml #418
I guess this is a bug in cordova, and not this plugin. A possible hack solution could be to clone this repo and...
Read more >
Cordova Android duplicated uses-feature from two plugins
Find the duplicate entry of permission and remove from anyone of the plugin there. Then open the AndroidManifest.xml and remove the duplicate entry...
Read more >
Ionic BarcodeScanner and QRScanner duplicated with ...
Ionic BarcodeScanner and QRScanner duplicated with element declared at AndroidManifest.xml · Go to cordova-plugin-qrscanner->plugin.xml · comment ...
Read more >
duplicated with element declared at AndroidManifest.xml ...
The latest Cordova Camera plugin (2.3.1) cannot be built with the Kapsel Logger plugin. When creating hybrid application for Android, error :.
Read more >
Duplicate elements declared in Androidmanifest - OutSystems
Hi Alberto, I got it working. I forked the barcode plugin git and took out the manifest part about the camera. Copied the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found