Skip to content

Unable to graft xml at selector "manifest/uses-sdk" #151

@breautek

Description

@breautek

Bug Report

Problem

What is expected to happen?

<edit-config> to apply changes to AndroidManifest.xml

What does actually happen?

An error occurs and the build fails.

Information

Error stacktrace:

Unable to graft xml at selector "/manifest/uses-sdk" from "C:\Users\norman\development\gradletest\platforms\android\app\src\main\AndroidManifest.xml" during config install
Error: Unable to graft xml at selector "/manifest/uses-sdk" from "C:\Users\norman\development\gradletest\platforms\android\app\src\main\AndroidManifest.xml" during config install
    at ConfigFile_graft_child [as graft_child] (C:\Users\norman\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigFile.js:120:19)
    at PlatformMunger_apply_file_munge [as apply_file_munge] (C:\Users\norman\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:81:34)
    at munge_helper (C:\Users\norman\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:238:14)
    at PlatformMunger.add_config_changes (C:\Users\norman\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:216:12)
    at C:\Users\norman\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:112:32
    at async Promise.all (index 0)

Command or Code

Use cordova create to build a simple hello world project.

Inside the config.xml add:

<edit-config file="AndroidManifest.xml" mode="overwrite" target="/manifest/uses-sdk">
    <uses-sdk android:minSdkVersion="16" android:maxSdkVersion="23" />
</edit-config>

This is a copied and paste example from the docs. But this appears to occur when having target="/manifest/uses-sdk", regardless of the body of <edit-config> block. This also fails if mode="merge" is set.

Do note that the following does not fail:

<edit-config file="AndroidManifest.xml" mode="merge" target="/manifest">
    <manifest xmlns:tools="http://schemas.android.com/tools" />
</edit-config>

This leads me to believe perhaps this occurs if the AndroidManifest.xml does not have the target node.

Finally run: cordova build android to observe the failure.

Environment, Platform, Device

Windows 10
Cordova-Android 9

Version information

Windows 10
cordova: 9.0.0 (cordova-lib@9.0.1)

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

    No labels
    No 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