Skip to content

Config changes not properly applied if paths differ but resolve to same file #110

@Lindsay-Needs-Sleep

Description

@Lindsay-Needs-Sleep

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_LOCK permission (and add uses-feature for 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 activity tag's theme property
<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 application tag's usesCleartextTraffic property
<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:
image

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 running cordova prepare android

Environment, Platform, Device

Windows 10

Version information

cordova -v
10.0.0-dev (cordova-lib@9.0.1)

In particular, cordova-cli commit 11ce340a47719060b57bcfe18852b20f21a69c65
cordova-android@8.1.0

Checklist

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions