cordova-ionic-phonegap-branch-deep-linking-attribution icon indicating copy to clipboard operation
cordova-ionic-phonegap-branch-deep-linking-attribution copied to clipboard

Can't install plugin: Cannot read property '0' of undefined

Open ElieSauveterre opened this issue 5 years ago • 16 comments

Since yesterday (September 18) the plugin install doesn't work, without having changed anything. I have a build pipeline with Gitlab CI. It's using a Docker image with all the dependencies preinstalled (npm, cordova, ionic...). A build that was working 2 days ago, is now failing.

I also have the same error on a blank ionic project (ionic start MyIonicProject tutorial --type=ionic-angular)

My console output:

ionic cordova plugin add branch-cordova-sdk cordova plugin add branch-cordova-sdk

You have been opted out of telemetry. To change this, run: cordova telemetry on. Plugin "branch-cordova-sdk" already installed on android. Adding branch-cordova-sdk to package.json Cannot read property '0' of undefined [ERROR] An error occurred while running subprocess cordova. cordova plugin add branch-cordova-sdk exited with exit code 1. Re-running this command with the --verbose flag may provide more information.

I'm using:

  • node 8.15.0
  • npm 6.7.0
  • ionic 5.2.3
  • cordova 8.1.2

I also tried with

  • node 8.15.0
  • npm 6.11.3
  • ionic 5.3.0
  • cordova 9.0.0

ElieSauveterre avatar Sep 19 '19 14:09 ElieSauveterre

I encountered the same problem. A week ago build was working but now cordova platform add android fails. Here's the error when running the command in verbose mode:

TypeError: Cannot read property '0' of undefined
    at getManifest (/Users/me/projects/project/project-cordova-deploy/project-web/plugins/branch-cordova-sdk/src/scripts/android/updateAndroidManifest.js:75:36)
    at Object.writePreferences (/Users/me/projects/project/project-cordova-deploy/project-web/plugins/branch-cordova-sdk/src/scripts/android/updateAndroidManifest.js:15:22)
    at platforms.forEach.platform (/Users/me/projects/project/project-cordova-deploy/project-web/plugins/branch-cordova-sdk/src/scripts/hooks/afterPrepare.js:20:25)
    at Array.forEach (<anonymous>)
    at run (/Users/me/projects/project/project-cordova-deploy/project-web/plugins/branch-cordova-sdk/src/scripts/hooks/afterPrepare.js:18:15)
    at runScriptViaModuleLoader (/Users/me/.nvm/versions/node/v10.15.3/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:196:18)
    at runScript (/Users/me/.nvm/versions/node/v10.15.3/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:172:16)
    at /Users/me/.nvm/versions/node/v10.15.3/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:140:20
    at _fulfilled (/Users/me/.nvm/versions/node/v10.15.3/lib/node_modules/cordova/node_modules/q/q.js:854:54)
    at /Users/me/.nvm/versions/node/v10.15.3/lib/node_modules/cordova/node_modules/q/q.js:883:30```

ronkot avatar Sep 19 '19 19:09 ronkot

This seems to be an issue with cordova-android 8.1.0. It doesn't seem to add the same records to AndroidManifest.xml that is used to and hence the branch-cordova-sdk cannot get the uses-sdk tag and determine the target sdk version.

When I specify the android version explicitly to an earlier version the problem no longer occurs i.e:

ionic cordova platform add [email protected]

psnfrench avatar Sep 20 '19 00:09 psnfrench

I encountered the same error. 4 days back every thing is working but now 'ionic cordova platform add android' fails .

yadhukrishnas avatar Sep 23 '19 11:09 yadhukrishnas

In my case I get the same error when adding the plugin. Also, there are other plugins that this happens too.

Ionic:

Ionic CLI : 5.4.1 (/usr/local/lib/node_modules/ionic) Ionic Framework : ionic1 1.3.4 @ionic/v1-toolkit : 1.0.13

Cordova:

Cordova CLI : 9.0.0 ([email protected]) Cordova Platforms : android 8.2.0-dev Cordova Plugins : cordova-plugin-ionic 5.4.4, cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.1.1, (and 12 other plugins)

Utility:

cordova-res : 0.6.0 native-run : not installed

System:

Android SDK Tools : 26.1.1 (/Users/adomvris/Library/Android/sdk/) ios-deploy : 1.9.2 NodeJS : v9.10.1 (/usr/local/bin/node) npm : 5.6.0 OS : macOS Mojave Xcode : Xcode 11.0 Build version 11A420a

deliverymanager avatar Sep 25 '19 09:09 deliverymanager

Here is the error:

Screenshot 2019-09-25 14 52 48

deliverymanager avatar Sep 25 '19 11:09 deliverymanager

Any update from the Branch team?

noahcooper avatar Sep 28 '19 10:09 noahcooper

uses-sdk should no longer be declared in the manifest, please check https://github.com/apache/cordova-android/issues/629

undersieg avatar Oct 01 '19 07:10 undersieg

In the version npm i branch-cordova-sdk@^4.0.0 be omit the requese targetVersionSdk use this version

Leo1305Pineda avatar Oct 22 '19 13:10 Leo1305Pineda

In the version npm i branch-cordova-sdk@^4.0.0 be omit the requese targetVersionSdk use this version

Just keep in mind that the tradeoff is that as of version 4.0.0, you have to manually build from Xcode. https://github.com/BranchMetrics/cordova-ionic-phonegap-branch-deep-linking-attribution/issues/601

noahcooper avatar Oct 22 '19 13:10 noahcooper

Any update from the Branch team?

Any news?

epetre avatar Dec 02 '19 17:12 epetre

Is this being worked on?

tryhardest avatar Dec 20 '19 17:12 tryhardest

Is this being worked on?

This is fixed in version 4.0.0, and now works properly with cordova-android 8.1.0. The problem is that version 4.0.0 introduces a change for iOS that makes it so that you cannot build from the command line and now have to build directly in Xcode. Super annoying, as it means that you're forced to choose to use a version that works with Android, or use a different version that works with iOS.

noahcooper avatar Dec 22 '19 15:12 noahcooper

@noahcooper did you find a work around? Or @adrianyg7 and way to get around this iOS bug on 4.0.0?

Mapiac avatar Jan 15 '20 07:01 Mapiac

@noahcooper @Mapiac you should be able to use 3.2.1 which is now published, which fixes the issue for cordova-android in the branch plugin's 3.x line.

If you're using cordova 8/9 and build using xcode, you'll want to use the 4.0 line. We know about the inability to build on the command line, it's an issue the iOS team will take on at some point but requires significant reorganization of the native library so will take some time.

codinronan avatar Jan 16 '20 23:01 codinronan

@echo-branch would it make sense to close this issue now?

codinronan avatar Jan 16 '20 23:01 codinronan

Version 3.2.1 works for me.

noahcooper avatar Feb 04 '20 18:02 noahcooper