[ https://issues.apache.org/jira/browse/CB-13486?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Audrey So updated CB-13486: --------------------------- Labels: reproduced triaged (was: ) > <config-file> adds duplicate element if the existing element has extra > attributes > --------------------------------------------------------------------------------- > > Key: CB-13486 > URL: https://issues.apache.org/jira/browse/CB-13486 > Project: Apache Cordova > Issue Type: Bug > Components: cordova-common > Affects Versions: 2.1.1 > Reporter: Ibrahim M. Ghazal > Labels: reproduced, triaged > > If {{<config-file>}} tries to add an element to a config file, and that > config file has the same element but with extra attributes, the element is > added anyway. I expect it to consider it already existing and skip adding it. > Example: > 1. Add {{cordova-plugin-file}} plugin, which contains this line in > {{plugin.xml}}: > {code} > <config-file target="AndroidManifest.xml" parent="/*"> > <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" > /> > </config-file> > {code} > 2. Since {{WRITE_EXTERNAL_STORAGE}} is not required on Android API 19+ > (Android 4.4+), I want to add {{android:maxSdkVersion="18"}} to the > permission. So I add this to the app's {{config.xml}} > {code} > <edit-config file="AndroidManifest.xml" mode="overwrite" > target="/manifest/uses-permission[@android:name='android.permission.WRITE_EXTERNAL_STORAGE']" > xmlns:android="http://schemas.android.com/apk/res/android"> > <uses-permission android:maxSdkVersion="18" > android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> > </edit-config> > {code} > 3. Run {{cordova run android}}. It succeeds the first time and the permission > is modified correctly. {{AndroidManifest.xml}} now contains this: > {code} > <uses-permission android:maxSdkVersion="18" > android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> > {code} > 3. Run {{cordova run android}} again. The {{<config-file>}} from > {{cordova-plugin-file}} is applied again. It searches for the exact element > it wants to add and doesn't find it (because that element now has an extra > attribute, {{android:maxSdkVersion}}), and so it adds it again. > {{AndroidManifest.xml}} now contains this: > {code} > <uses-permission android:maxSdkVersion="18" > android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> > <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> > {code} > This causes {{cordova run android}} to fail with: > {code} > Element uses-permission#android.permission.WRITE_EXTERNAL_STORAGE at > AndroidManifest.xml:20:5-81 duplicated with element declared at > AndroidManifest.xml:18:5-108 > See http://g.co/androidstudio/manifest-merger for more information about the > manifest merger. > {code} -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org