Search code examples
androidcordovaionic-frameworkcordova-android

Unable to graft xml at selector "undefined" AndroidManifest.xml during config install


So I am getting the following error when I attempt to add the android platform to my ionic project. It is an existing project where I am updating the version of cordova used, I have attempted various versions of android cordova with all of them the exact same issue, I can not find anything on the web, except for something related to blackberry, I have removed and re-added the platform a few times with no success, keep on getting the same error:

> cordova platform add [email protected] --save
Running command: cmd "/s /c ""C:\PROGRAM FILES\NODEJS\NODE.EXE" "E:\Development\StrikeMedia BitBucket\SpurHybridAppVersion2\hooks\before_platform_add\init_directories.js" "E:\Development\StrikeMedia BitBucket\SpurHybridAppVersion2"""

Using cordova-fetch for [email protected]

Adding android project...

Creating Cordova project for the Android platform:

        Path: platforms\android
        Package: com.gloo.familycard
        Name: Spur
        Activity: MainActivity
        Android target: android-27
Subproject Path: CordovaLib
Subproject Path: app
Android project created with [email protected]
Android Studio project detected

Android Studio project detected
(node:23852) UnhandledPromiseRejectionWarning: Error: Unable to graft xml at selector "undefined" from "E:\Development\StrikeMedia BitBucket\SpurHybridAppVersion2\platforms\android\app\src\main\AndroidManifest.xml" during config install
    at ConfigFile_graft_child [as graft_child] (C:\Users\Armand van der Walt\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigFile.js:122:19)
    at PlatformMunger_apply_file_munge [as apply_file_munge] (C:\Users\Armand van der Walt\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:81:34)
    at munge_helper (C:\Users\Armand van der Walt\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:238:14)
    at PlatformMunger.add_config_changes (C:\Users\Armand van der Walt\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-common\src\ConfigChanges\ConfigChanges.js:216:12)
    at C:\Users\Armand van der Walt\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\cordova\prepare.js:130:32
    at _fulfilled (E:\Development\StrikeMedia BitBucket\SpurHybridAppVersion2\platforms\android\cordova\node_modules\q\q.js:854:54)
    at self.promiseDispatch.done (E:\Development\StrikeMedia BitBucket\SpurHybridAppVersion2\platforms\android\cordova\node_modules\q\q.js:883:30)
    at Promise.promise.promiseDispatch (E:\Development\StrikeMedia BitBucket\SpurHybridAppVersion2\platforms\android\cordova\node_modules\q\q.js:816:13)
    at E:\Development\StrikeMedia BitBucket\SpurHybridAppVersion2\platforms\android\cordova\node_modules\q\q.js:624:44
    at runSingle (E:\Development\StrikeMedia BitBucket\SpurHybridAppVersion2\platforms\android\cordova\node_modules\q\q.js:137:13)
(node:23852) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:23852) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The commands I have tried so far

ionic cordova platform add [email protected]
ionic cordova platform add [email protected]
ionic cordova platform add android@latest
ionic cordova platform add android

ionic info

[WARN] Error with .\www\lib\ionic\version.json file: FILE_NOT_FOUND, trying .\bower.json.

cli packages: (C:\Users\Armand van der Walt\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.19.2
    ionic (Ionic CLI) : 3.20.0

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    Cordova Platforms : android 7.1.0
    Ionic Framework   : ionic1 1.2.4

System:

    Android SDK Tools : 26.1.1
    Node              : v9.4.0
    npm               : 5.6.0
    OS                : Windows 10

Environment Variables:

    ANDROID_HOME : E:\Android\sdk

Misc:

    backend : pro

Solution

  • In the end I had to uninstall cordova and ionic, remove the platforms from the project, and then re-install everything and re-add the platforms to make it work again.