Config changes not properly applied if paths differ but resolve to same file
Bug Report
Problem
config-file and edit-config options in config.xml do not work properly.
I am trying to make 3 modifications to AndroidManifest.xml:
- Add
WAKE_LOCKpermission (and adduses-featurefor touchscreen)
<config-file parent="/manifest" target="AndroidManifest.xml">
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature android:name="android.hardware.touchscreen" android:required="true" />
</config-file>
- Modify
activitytag'sthemeproperty
<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest/application/activity[@android:label='@string/activity_name']">
<activity android:theme="@style/Theme.FullScreen.Splash" />
</edit-config>
- Modify
applicationtag'susesCleartextTrafficproperty
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application">
<application android:usesCleartextTraffic="true" />
</edit-config>
Depending on the order these config-file and edit-config tags appear in config.xml the result is different.
What is expected to happen?
Expected AndroidManifest.xml to have all 3 updates:
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:usesCleartextTraffic="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@style/Theme.FullScreen.Splash" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature android:name="android.hardware.touchscreen" android:required="true" />
What does actually happen?
Depending on the order these config-file and edit-config tags appear in config.xml the result is different.
I can only get either: [WAKE_LOCK and Theme], or [clearText].
[WAKE_LOCK and Theme]:
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@style/Theme.FullScreen.Splash" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature android:name="android.hardware.touchscreen" android:required="true" />
[clearText]:
<application android:hardwareAccelerated="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsRtl="true" android:usesCleartextTraffic="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|smallestScreenSize|screenLayout|uiMode" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Summary of the different order combinations > results:

Information
Command or Code
I have tried refreshing AndroidManifest.xml with:
cordova platform rm android && cordova platfrom add android- Deleting
/platforms,/node_modules, and/plugins, and runningcordova prepare android
Environment, Platform, Device
Windows 10
Version information
cordova -v
10.0.0-dev ([email protected])
In particular, cordova-cli commit 11ce340a47719060b57bcfe18852b20f21a69c65
[email protected]
Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
Could you test if the problem persists with cordova@nightly? Also do a cordova platform rm android && cordova platfrom add android@nightly using the nightly, before testing.
Yep! I’ll do it in the morning! (~14hrs)
I have tried it with cordova@nightly, the result is the same.
I created a new cordova project that demonstrates it: https://github.com/Lindsay-Needs-Sleep/cordova-cli_Issue-491
Sorry for taking so long to come back to this. I could reproduce the problem, and finally I could figure out that it works if you ensure that all three edit-config/config-file tags have their file/target attributes set to the same value. While AndroidManifest.xml is expanded to app/src/main/AndroidManifest.xml in cordova-common, I guess that the following is happening:
- the config changes are grouped by target file to prevent conflicts
- this is done before the file name expansion, leaving your original config edit jobs in separate groups for
AndroidManifest.xmlandapp/src/main/AndroidManifest.xmlrespectively - changes from both groups are applied to the original
AndroidManifest.xmlwith the result written to the destination. Last group wins.
Fortunately you can work around the issue, while we try to fix it.
@raphinesse Thanks so much! (Np, about the time. I totally get that.)
I didn't even realize I had used two different targets. Thanks for providing the work around!!