apache / apache/cordova-common

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

Open
#151 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
42
Forks
45
Avg merge
5h 41m
Merged PRs (30d)
6

Description

# Bug Report

## Problem

### What is expected to happen?

`` 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:

```xml

```

This is a copied and paste example from the [docs](https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#edit-config). But this appears to occur when having `target="/manifest/uses-sdk"`, regardless of the body of `` block. This also fails if `mode="merge"` is set.

Do note that the following does **not** fail:

```xml

```

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

- [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

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the documented edit-config example and cordova build android, then inspect ConfigChanges/ConfigFile.js at the graft_child path shown in the stack trace. Compare the /manifest/uses-sdk case with the working /manifest target case and check related config-change handling. Done means the example applies successfully without the graft error and the Android build completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, javascript
Domain
mobile-dev, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.