Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-13308

Error on installation of a plugin's dependency that is also a direct dependency

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • cordova@7.0.0
    • None
    • cordova-lib

    Description

      Summary

      I'm using the plugins cordova-plugin-device and cordova-plugin-background-mode (which itself depends on cordova-plugin-device) in a project. The following error occurred, when the background-mode plugins was defined before the device plugin in config.xml:

      Failed to install 'cordova-plugin-background-mode': Error
      at /home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:215:37
      at _rejected (/home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:864:24)
      at /home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:890:30
      at Promise.when (/home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:1142:31)
      at Promise.promise.promiseDispatch (/home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:808:41)
      at /home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:624:44
      at runSingle (/home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:137:13)
      at flush (/home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:125:13)
      at _combinedTickCallback (internal/process/next_tick.js:131:7)
      at process._tickCallback (internal/process/next_tick.js:180:9)

      This error does not happen, if cordova-plugin-device is not defined as direct dependency, or if it is defined before background-mode in config.xml.

      Steps to reproduce

      I setup a brand new project:

      ✔ ~
      $ cordova create hello com.example.hello HelloWorld
      Warning: using prerelease version 7.0.2-nightly.2017.9.20.596da5df (cordova-lib@7.0.2-nightly.2017.9.20.701c15fe)
      Creating a new cordova project.
      ✔ ~
      $ cd hello/
      ✔ ~/hello
      $ cordova platform add android
      Warning: using prerelease version 7.0.2-nightly.2017.9.20.596da5df (cordova-lib@7.0.2-nightly.2017.9.20.701c15fe)
      Using cordova-fetch for cordova-android@6.3.0-nightly.2017.9.20.dddb2837
      Warning: using prerelease platform android@6.3.0-nightly.2017.9.20.dddb2837.
      Use 'cordova platform add android@latest' to add the latest published version instead.
      Adding android project...
      Creating Cordova project for the Android platform:
      Path: platforms/android
      Package: com.example.hello
      Name: HelloWorld
      Activity: MainActivity
      Android target: android-26
      Subproject Path: CordovaLib
      Android project created with cordova-android@6.3.0-nightly.2017.9.20.dddb2837
      Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
      Installing "cordova-plugin-whitelist" for android

      This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do not need this plugin since the whitelist will be built in.

      Adding cordova-plugin-whitelist to package.json
      Saved plugin info for "cordova-plugin-whitelist" to config.xml
      --save flag or autosave detected
      Saving android@~6.3.0-nightly.2017.9.20.dddb2837 into config.xml file ...}}

      I add the device plugin:

      ✔ ~/hello
      $ cordova plugin add cordova-plugin-device
      Warning: using prerelease version 7.0.2-nightly.2017.9.20.596da5df (cordova-lib@7.0.2-nightly.2017.9.20.701c15fe)
      Installing "cordova-plugin-device" for android
      Adding cordova-plugin-device to package.json
      Saved plugin info for "cordova-plugin-device" to config.xml
      ✔ ~/hello
      $ cat package.json
      {
      "name": "com.example.hello",
      "displayName": "HelloWorld",
      "version": "1.0.0",
      "description": "A sample Apache Cordova application that responds to the deviceready event.",
      "main": "index.js",
      "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "Apache Cordova Team",
      "license": "Apache-2.0",
      "dependencies": {
      "cordova-android": "^6.3.0-nightly.2017.9.20.dddb2837",
      "cordova-plugin-device": "^1.1.6",
      "cordova-plugin-whitelist": "^1.3.2"
      },
      "cordova": {
      "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {}
      },
      "platforms": [
      "android"
      ]
      }
      }✔ ~/hello
      $ cat config.xml
      <?xml version='1.0' encoding='utf-8'?>
      <widget id="com.example.hello" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
      <name>HelloWorld</name>
      <description>
      A sample Apache Cordova application that responds to the deviceready event.
      </description>
      <author email="dev@cordova.apache.org" href="http://cordova.io">
      Apache Cordova Team
      </author>
      <content src="index.html" />
      <plugin name="cordova-plugin-whitelist" spec="1" />
      <access origin="*" />
      <allow-intent href="http:///" />
      <allow-intent href="https:///" />
      <allow-intent href="tel:*" />
      <allow-intent href="sms:*" />
      <allow-intent href="mailto:*" />
      <allow-intent href="geo:*" />
      <platform name="android">
      <allow-intent href="market:*" />
      </platform>
      <platform name="ios">
      <allow-intent href="itms:*" />
      <allow-intent href="itms-apps:*" />
      </platform>
      <engine name="android" spec="~6.3.0-nightly.2017.9.20.dddb2837" />
      <plugin name="cordova-plugin-device" spec="^1.1.6" />
      </widget>

      When removing the platforms and plugins directories and doing a cordova prepare, everything looks fine:

      ✔ ~/hello
      $ rm -rf platforms/ plugins/
      ✔ ~/hello
      $ cordova prepare --verbose
      Warning: using prerelease version 7.0.2-nightly.2017.9.20.596da5df (cordova-lib@7.0.2-nightly.2017.9.20.701c15fe)
      No scripts found for hook "before_prepare".
      Checking config.xml and package.json for saved platforms that haven't been added to the project
      Config.xml and package.json platforms are the same. No pkg.json modification.
      Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
      Discovered platform "android@^6.3.0-nightly.2017.9.20.dddb2837" in config.xml or package.json. Adding it to the project
      No scripts found for hook "before_platform_add".
      Using cordova-fetch for cordova-android@^6.3.0-nightly.2017.9.20.dddb2837
      Running command: npm install cordova-android@^6.3.0-nightly.2017.9.20.dddb2837
      Command finished with error code 0: npm install,cordova-android@^6.3.0-nightly.2017.9.20.dddb2837
      Removing "cordova-" prefix from cordova-android
      Warning: using prerelease platform android@6.3.0-nightly.2017.9.21.dddb2837.
      Use 'cordova platform add android@latest' to add the latest published version instead.
      Adding android project...
      PlatformApi successfully found for platform android
      Creating Cordova project for the Android platform:
      Path: platforms/android
      Package: com.example.hello
      Name: HelloWorld
      Activity: MainActivity
      Android target: android-26
      Copying android template project to platforms/android
      Subproject Path: CordovaLib
      Android project created with cordova-android@6.3.0-nightly.2017.9.21.dddb2837
      Saving android@6.3.0-nightly.2017.9.21.dddb2837 into platforms.json
      No scripts found for hook "after_platform_add".
      PlatformApi successfully found for platform android
      Checking config.xml for saved plugins that haven't been added to the project
      Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
      No scripts found for hook "before_plugin_add".
      Calling plugman.fetch on plugin "cordova-plugin-whitelist@^1.3.2"
      Running command: npm install cordova-plugin-whitelist@^1.3.2
      Command finished with error code 0: npm install,cordova-plugin-whitelist@^1.3.2
      Copying plugin "/home/mhofer/hello/node_modules/cordova-plugin-whitelist" => "/home/mhofer/hello/plugins/cordova-plugin-whitelist"
      Calling plugman.install on plugin "/home/mhofer/hello/plugins/cordova-plugin-whitelist" for platform "android
      Installing "cordova-plugin-whitelist" for android
      Running command: /home/mhofer/hello/platforms/android/cordova/version
      Command finished with error code 0: /home/mhofer/hello/platforms/android/cordova/version
      Finding scripts for "before_plugin_install" hook from plugin cordova-plugin-whitelist on android platform only.
      No scripts found for hook "before_plugin_install".
      Install start for "cordova-plugin-whitelist" on android.
      Beginning processing of action stack for android project...
      Action stack processing complete.
      Install complete for cordova-plugin-whitelist on android.

      This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do not need this plugin since the whitelist will be built in.

      Finding scripts for "after_plugin_install" hook from plugin cordova-plugin-whitelist on android platform only.
      No scripts found for hook "after_plugin_install".
      No scripts found for hook "after_plugin_add".
      Discovered plugin "cordova-plugin-device" in config.xml. Adding it to the project
      No scripts found for hook "before_plugin_add".
      Calling plugman.fetch on plugin "cordova-plugin-device@^1.1.6"
      Running command: npm install cordova-plugin-device@^1.1.6
      Command finished with error code 0: npm install,cordova-plugin-device@^1.1.6
      Copying plugin "/home/mhofer/hello/node_modules/cordova-plugin-device" => "/home/mhofer/hello/plugins/cordova-plugin-device"
      Calling plugman.install on plugin "/home/mhofer/hello/plugins/cordova-plugin-device" for platform "android
      Installing "cordova-plugin-device" for android
      Running command: /home/mhofer/hello/platforms/android/cordova/version
      Command finished with error code 0: /home/mhofer/hello/platforms/android/cordova/version
      Finding scripts for "before_plugin_install" hook from plugin cordova-plugin-device on android platform only.
      No scripts found for hook "before_plugin_install".
      Install start for "cordova-plugin-device" on android.
      Beginning processing of action stack for android project...
      Action stack processing complete.
      Install complete for cordova-plugin-device on android.
      Finding scripts for "after_plugin_install" hook from plugin cordova-plugin-device on android platform only.
      No scripts found for hook "after_plugin_install".
      No scripts found for hook "after_plugin_add".
      Checking for any plugins added to the project that have not been installed in android platform
      No differences found between plugins added to project and installed in android platform. Continuing...
      Generating platform-specific config.xml from defaults for android at /home/mhofer/hello/platforms/android/res/xml/config.xml
      Merging project's config.xml into platform-specific android config.xml
      Merging and updating files from [www, platforms/android/platform_www] to platforms/android/assets/www
      mkdir platforms/android/assets/www/cordova-js-src
      mkdir platforms/android/assets/www/cordova-js-src/android
      copy platforms/android/platform_www/cordova-js-src/android/nativeapiprovider.js platforms/android/assets/www/cordova-js-src/android/nativeapiprovider.js (new file)
      copy platforms/android/platform_www/cordova-js-src/android/promptbasednativeapi.js platforms/android/assets/www/cordova-js-src/android/promptbasednativeapi.js (new file)
      copy platforms/android/platform_www/cordova-js-src/exec.js platforms/android/assets/www/cordova-js-src/exec.js (new file)
      copy platforms/android/platform_www/cordova-js-src/platform.js platforms/android/assets/www/cordova-js-src/platform.js (new file)
      mkdir platforms/android/assets/www/cordova-js-src/plugin
      mkdir platforms/android/assets/www/cordova-js-src/plugin/android
      copy platforms/android/platform_www/cordova-js-src/plugin/android/app.js platforms/android/assets/www/cordova-js-src/plugin/android/app.js (new file)
      copy platforms/android/platform_www/cordova.js platforms/android/assets/www/cordova.js (updated file)
      copy platforms/android/platform_www/cordova_plugins.js platforms/android/assets/www/cordova_plugins.js (updated file)
      delete platforms/android/assets/www/img/cordova.png (no source)
      copy www/index.html platforms/android/assets/www/index.html (updated file)
      copy www/js/index.js platforms/android/assets/www/js/index.js (updated file)
      copy platforms/android/platform_www/plugins/cordova-plugin-device/www/device.js platforms/android/assets/www/plugins/cordova-plugin-device/www/device.js (updated file)
      Wrote out android application name "HelloWorld" to /home/mhofer/hello/platforms/android/res/values/strings.xml
      android-versionCode not found in config.xml. Generating a code based on version in config.xml (1.0.0): 10000
      Wrote out Android package name "com.example.hello" to /home/mhofer/hello/platforms/android/src/com/example/hello/MainActivity.java
      This app does not have launcher icons defined
      This app does not have splash screens defined
      This app does not have additional resource files defined
      Prepared android project successfully
      No scripts found for hook "after_prepare".

      I then add the background-mode plugin:

      ✔ ~/hello
      $ cordova plugin add cordova-plugin-background-mode
      Warning: using prerelease version 7.0.2-nightly.2017.9.20.596da5df (cordova-lib@7.0.2-nightly.2017.9.20.701c15fe)
      Installing "cordova-plugin-background-mode" for android
      Plugin dependency "cordova-plugin-device@1.1.6" already fetched, using that version.
      Dependent plugin "cordova-plugin-device" already installed on android.
      Adding cordova-plugin-background-mode to package.json
      Saved plugin info for "cordova-plugin-background-mode" to config.xml
      ✔ ~/hello
      $ cat package.json
      {
      "name": "com.example.hello",
      "displayName": "HelloWorld",
      "version": "1.0.0",
      "description": "A sample Apache Cordova application that responds to the deviceready event.",
      "main": "index.js",
      "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "Apache Cordova Team",
      "license": "Apache-2.0",
      "dependencies": {
      "cordova-android": "^6.3.0-nightly.2017.9.21.dddb2837",
      "cordova-plugin-background-mode": "^0.7.2",
      "cordova-plugin-device": "^1.1.6",
      "cordova-plugin-whitelist": "^1.3.2"
      },
      "cordova": {
      "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-background-mode": {}
      },
      "platforms": [
      "android"
      ]
      }
      }✔ ~/hello
      $ cat config.xml
      <?xml version='1.0' encoding='utf-8'?>
      <widget id="com.example.hello" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
      <name>HelloWorld</name>
      <description>
      A sample Apache Cordova application that responds to the deviceready event.
      </description>
      <author email="dev@cordova.apache.org" href="http://cordova.io">
      Apache Cordova Team
      </author>
      <content src="index.html" />
      <access origin="*" />
      <allow-intent href="http:///" />
      <allow-intent href="https:///" />
      <allow-intent href="tel:*" />
      <allow-intent href="sms:*" />
      <allow-intent href="mailto:*" />
      <allow-intent href="geo:*" />
      <platform name="android">
      <allow-intent href="market:*" />
      </platform>
      <platform name="ios">
      <allow-intent href="itms:*" />
      <allow-intent href="itms-apps:*" />
      </platform>
      <engine name="android" spec="^6.3.0-nightly.2017.9.20.dddb2837" />
      <plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
      <plugin name="cordova-plugin-device" spec="^1.1.6" />
      <plugin name="cordova-plugin-background-mode" spec="^0.7.2" />
      </widget>

      Still, the prepare works as expected:

      ✔ ~/hello
      $ rm -rf platforms/ plugins/
      ✔ ~/hello
      $ cordova prepare --verbose
      Warning: using prerelease version 7.0.2-nightly.2017.9.20.596da5df (cordova-lib@7.0.2-nightly.2017.9.20.701c15fe)
      No scripts found for hook "before_prepare".
      Checking config.xml and package.json for saved platforms that haven't been added to the project
      Config.xml and package.json platforms are the same. No pkg.json modification.
      Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
      Discovered platform "android@^6.3.0-nightly.2017.9.21.dddb2837" in config.xml or package.json. Adding it to the project
      No scripts found for hook "before_platform_add".
      Using cordova-fetch for cordova-android@^6.3.0-nightly.2017.9.21.dddb2837
      Running command: npm install cordova-android@^6.3.0-nightly.2017.9.21.dddb2837
      Command finished with error code 0: npm install,cordova-android@^6.3.0-nightly.2017.9.21.dddb2837
      Removing "cordova-" prefix from cordova-android
      Warning: using prerelease platform android@6.3.0-nightly.2017.9.21.dddb2837.
      Use 'cordova platform add android@latest' to add the latest published version instead.
      Adding android project...
      PlatformApi successfully found for platform android
      Creating Cordova project for the Android platform:
      Path: platforms/android
      Package: com.example.hello
      Name: HelloWorld
      Activity: MainActivity
      Android target: android-26
      Copying android template project to platforms/android
      Subproject Path: CordovaLib
      Android project created with cordova-android@6.3.0-nightly.2017.9.21.dddb2837
      Saving android@6.3.0-nightly.2017.9.21.dddb2837 into platforms.json
      No scripts found for hook "after_platform_add".
      PlatformApi successfully found for platform android
      Checking config.xml for saved plugins that haven't been added to the project
      Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
      No scripts found for hook "before_plugin_add".
      Calling plugman.fetch on plugin "cordova-plugin-whitelist@^1.3.2"
      Running command: npm install cordova-plugin-whitelist@^1.3.2
      Command finished with error code 0: npm install,cordova-plugin-whitelist@^1.3.2
      Copying plugin "/home/mhofer/hello/node_modules/cordova-plugin-whitelist" => "/home/mhofer/hello/plugins/cordova-plugin-whitelist"
      Calling plugman.install on plugin "/home/mhofer/hello/plugins/cordova-plugin-whitelist" for platform "android
      Installing "cordova-plugin-whitelist" for android
      Running command: /home/mhofer/hello/platforms/android/cordova/version
      Command finished with error code 0: /home/mhofer/hello/platforms/android/cordova/version
      Finding scripts for "before_plugin_install" hook from plugin cordova-plugin-whitelist on android platform only.
      No scripts found for hook "before_plugin_install".
      Install start for "cordova-plugin-whitelist" on android.
      Beginning processing of action stack for android project...
      Action stack processing complete.
      Install complete for cordova-plugin-whitelist on android.

      This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do not need this plugin since the whitelist will be built in.

      Finding scripts for "after_plugin_install" hook from plugin cordova-plugin-whitelist on android platform only.
      No scripts found for hook "after_plugin_install".
      No scripts found for hook "after_plugin_add".
      Discovered plugin "cordova-plugin-device" in config.xml. Adding it to the project
      No scripts found for hook "before_plugin_add".
      Calling plugman.fetch on plugin "cordova-plugin-device@^1.1.6"
      Running command: npm install cordova-plugin-device@^1.1.6
      Command finished with error code 0: npm install,cordova-plugin-device@^1.1.6
      Copying plugin "/home/mhofer/hello/node_modules/cordova-plugin-device" => "/home/mhofer/hello/plugins/cordova-plugin-device"
      Calling plugman.install on plugin "/home/mhofer/hello/plugins/cordova-plugin-device" for platform "android
      Installing "cordova-plugin-device" for android
      Running command: /home/mhofer/hello/platforms/android/cordova/version
      Command finished with error code 0: /home/mhofer/hello/platforms/android/cordova/version
      Finding scripts for "before_plugin_install" hook from plugin cordova-plugin-device on android platform only.
      No scripts found for hook "before_plugin_install".
      Install start for "cordova-plugin-device" on android.
      Beginning processing of action stack for android project...
      Action stack processing complete.
      Install complete for cordova-plugin-device on android.
      Finding scripts for "after_plugin_install" hook from plugin cordova-plugin-device on android platform only.
      No scripts found for hook "after_plugin_install".
      No scripts found for hook "after_plugin_add".
      Discovered plugin "cordova-plugin-background-mode" in config.xml. Adding it to the project
      No scripts found for hook "before_plugin_add".
      Calling plugman.fetch on plugin "cordova-plugin-background-mode@^0.7.2"
      Running command: npm install cordova-plugin-background-mode@^0.7.2
      Command finished with error code 0: npm install,cordova-plugin-background-mode@^0.7.2
      Copying plugin "/home/mhofer/hello/node_modules/cordova-plugin-background-mode" => "/home/mhofer/hello/plugins/cordova-plugin-background-mode"
      Calling plugman.install on plugin "/home/mhofer/hello/plugins/cordova-plugin-background-mode" for platform "android
      Installing "cordova-plugin-background-mode" for android
      Running command: /home/mhofer/hello/platforms/android/cordova/version
      Command finished with error code 0: /home/mhofer/hello/platforms/android/cordova/version
      Dependencies detected, iterating through them...
      Requesting plugin "cordova-plugin-device".
      Plugin dependency "cordova-plugin-device@1.1.6" already fetched, using that version.
      Dependent plugin "cordova-plugin-device" already installed on android.
      Finding scripts for "before_plugin_install" hook from plugin cordova-plugin-background-mode on android platform only.
      No scripts found for hook "before_plugin_install".
      Install start for "cordova-plugin-background-mode" on android.
      Beginning processing of action stack for android project...
      Action stack processing complete.
      Install complete for cordova-plugin-background-mode on android.
      Finding scripts for "after_plugin_install" hook from plugin cordova-plugin-background-mode on android platform only.
      No scripts found for hook "after_plugin_install".
      No scripts found for hook "after_plugin_add".
      Checking for any plugins added to the project that have not been installed in android platform
      No differences found between plugins added to project and installed in android platform. Continuing...
      Generating platform-specific config.xml from defaults for android at /home/mhofer/hello/platforms/android/res/xml/config.xml
      Merging project's config.xml into platform-specific android config.xml
      Merging and updating files from [www, platforms/android/platform_www] to platforms/android/assets/www
      mkdir platforms/android/assets/www/cordova-js-src
      mkdir platforms/android/assets/www/cordova-js-src/android
      copy platforms/android/platform_www/cordova-js-src/android/nativeapiprovider.js platforms/android/assets/www/cordova-js-src/android/nativeapiprovider.js (new file)
      copy platforms/android/platform_www/cordova-js-src/android/promptbasednativeapi.js platforms/android/assets/www/cordova-js-src/android/promptbasednativeapi.js (new file)
      copy platforms/android/platform_www/cordova-js-src/exec.js platforms/android/assets/www/cordova-js-src/exec.js (new file)
      copy platforms/android/platform_www/cordova-js-src/platform.js platforms/android/assets/www/cordova-js-src/platform.js (new file)
      mkdir platforms/android/assets/www/cordova-js-src/plugin
      mkdir platforms/android/assets/www/cordova-js-src/plugin/android
      copy platforms/android/platform_www/cordova-js-src/plugin/android/app.js platforms/android/assets/www/cordova-js-src/plugin/android/app.js (new file)
      copy platforms/android/platform_www/cordova.js platforms/android/assets/www/cordova.js (updated file)
      copy platforms/android/platform_www/cordova_plugins.js platforms/android/assets/www/cordova_plugins.js (updated file)
      delete platforms/android/assets/www/img/cordova.png (no source)
      copy www/index.html platforms/android/assets/www/index.html (updated file)
      copy www/js/index.js platforms/android/assets/www/js/index.js (updated file)
      copy platforms/android/platform_www/plugins/cordova-plugin-background-mode/www/background-mode.js platforms/android/assets/www/plugins/cordova-plugin-background-mode/www/background-mode.js (updated file)
      copy platforms/android/platform_www/plugins/cordova-plugin-device/www/device.js platforms/android/assets/www/plugins/cordova-plugin-device/www/device.js (updated file)
      Wrote out android application name "HelloWorld" to /home/mhofer/hello/platforms/android/res/values/strings.xml
      android-versionCode not found in config.xml. Generating a code based on version in config.xml (1.0.0): 10000
      Wrote out Android package name "com.example.hello" to /home/mhofer/hello/platforms/android/src/com/example/hello/MainActivity.java
      This app does not have launcher icons defined
      This app does not have splash screens defined
      This app does not have additional resource files defined
      Prepared android project successfully
      No scripts found for hook "after_prepare".

      I now switch the order of these two plugins in config.xml:

      ✔ ~/hello
      $ cat config.xml
      <?xml version='1.0' encoding='utf-8'?>
      <widget id="com.example.hello" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
      <name>HelloWorld</name>
      <description>
      A sample Apache Cordova application that responds to the deviceready event.
      </description>
      <author email="dev@cordova.apache.org" href="http://cordova.io">
      Apache Cordova Team
      </author>
      <content src="index.html" />
      <access origin="*" />
      <allow-intent href="http:///" />
      <allow-intent href="https:///" />
      <allow-intent href="tel:*" />
      <allow-intent href="sms:*" />
      <allow-intent href="mailto:*" />
      <allow-intent href="geo:*" />
      <platform name="android">
      <allow-intent href="market:*" />
      </platform>
      <platform name="ios">
      <allow-intent href="itms:*" />
      <allow-intent href="itms-apps:*" />
      </platform>
      <engine name="android" spec="^6.3.0-nightly.2017.9.20.dddb2837" />
      <plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
      <plugin name="cordova-plugin-background-mode" spec="^0.7.2" />
      <plugin name="cordova-plugin-device" spec="^1.1.6" />
      </widget>

      And again do the prepare, this time it causes the error:

      ✔ ~/hello
      $ rm -rf platforms/ plugins/
      ✔ ~/hello
      $ cordova prepare --verbose
      Warning: using prerelease version 7.0.2-nightly.2017.9.20.596da5df (cordova-lib@7.0.2-nightly.2017.9.20.701c15fe)
      No scripts found for hook "before_prepare".
      Checking config.xml and package.json for saved platforms that haven't been added to the project
      Config.xml and package.json platforms are the same. No pkg.json modification.
      Package.json and config.xml platforms are different. Updating config.xml with most current list of platforms.
      Discovered platform "android@^6.3.0-nightly.2017.9.21.dddb2837" in config.xml or package.json. Adding it to the project
      No scripts found for hook "before_platform_add".
      Using cordova-fetch for cordova-android@^6.3.0-nightly.2017.9.21.dddb2837
      Running command: npm install cordova-android@^6.3.0-nightly.2017.9.21.dddb2837
      Command finished with error code 0: npm install,cordova-android@^6.3.0-nightly.2017.9.21.dddb2837
      Removing "cordova-" prefix from cordova-android
      Warning: using prerelease platform android@6.3.0-nightly.2017.9.21.dddb2837.
      Use 'cordova platform add android@latest' to add the latest published version instead.
      Adding android project...
      PlatformApi successfully found for platform android
      Creating Cordova project for the Android platform:
      Path: platforms/android
      Package: com.example.hello
      Name: HelloWorld
      Activity: MainActivity
      Android target: android-26
      Copying android template project to platforms/android
      Subproject Path: CordovaLib
      Android project created with cordova-android@6.3.0-nightly.2017.9.21.dddb2837
      Saving android@6.3.0-nightly.2017.9.21.dddb2837 into platforms.json
      No scripts found for hook "after_platform_add".
      PlatformApi successfully found for platform android
      Checking config.xml for saved plugins that haven't been added to the project
      Discovered plugin "cordova-plugin-whitelist" in config.xml. Adding it to the project
      No scripts found for hook "before_plugin_add".
      Calling plugman.fetch on plugin "cordova-plugin-whitelist@^1.3.2"
      Running command: npm install cordova-plugin-whitelist@^1.3.2
      Command finished with error code 0: npm install,cordova-plugin-whitelist@^1.3.2
      Copying plugin "/home/mhofer/hello/node_modules/cordova-plugin-whitelist" => "/home/mhofer/hello/plugins/cordova-plugin-whitelist"
      Calling plugman.install on plugin "/home/mhofer/hello/plugins/cordova-plugin-whitelist" for platform "android
      Installing "cordova-plugin-whitelist" for android
      Running command: /home/mhofer/hello/platforms/android/cordova/version
      Command finished with error code 0: /home/mhofer/hello/platforms/android/cordova/version
      Finding scripts for "before_plugin_install" hook from plugin cordova-plugin-whitelist on android platform only.
      No scripts found for hook "before_plugin_install".
      Install start for "cordova-plugin-whitelist" on android.
      Beginning processing of action stack for android project...
      Action stack processing complete.
      Install complete for cordova-plugin-whitelist on android.

      This plugin is only applicable for versions of cordova-android greater than 4.0. If you have a previous platform version, you do not need this plugin since the whitelist will be built in.

      Finding scripts for "after_plugin_install" hook from plugin cordova-plugin-whitelist on android platform only.
      No scripts found for hook "after_plugin_install".
      No scripts found for hook "after_plugin_add".
      Discovered plugin "cordova-plugin-background-mode" in config.xml. Adding it to the project
      No scripts found for hook "before_plugin_add".
      Calling plugman.fetch on plugin "cordova-plugin-background-mode@^0.7.2"
      Running command: npm install cordova-plugin-background-mode@^0.7.2
      Command finished with error code 0: npm install,cordova-plugin-background-mode@^0.7.2
      Copying plugin "/home/mhofer/hello/node_modules/cordova-plugin-background-mode" => "/home/mhofer/hello/plugins/cordova-plugin-background-mode"
      Calling plugman.install on plugin "/home/mhofer/hello/plugins/cordova-plugin-background-mode" for platform "android
      Installing "cordova-plugin-background-mode" for android
      Running command: /home/mhofer/hello/platforms/android/cordova/version
      Command finished with error code 0: /home/mhofer/hello/platforms/android/cordova/version
      Dependencies detected, iterating through them...
      Requesting plugin "cordova-plugin-device".
      Plugin dependency "cordova-plugin-device" not fetched, retrieving then installing.
      Running command: npm install cordova-plugin-device
      Command finished with error code 0: npm install,cordova-plugin-device
      Failed to install 'cordova-plugin-background-mode': Error
      at /home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/fetch.js:215:37
      at _rejected (/home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:864:24)
      at /home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:890:30
      at Promise.when (/home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:1142:31)
      at Promise.promise.promiseDispatch (/home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:808:41)
      at /home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:624:44
      at runSingle (/home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:137:13)
      at flush (/home/mhofer/.nvm/versions/node/v8.3.0/lib/node_modules/cordova/node_modules/cordova-fetch/node_modules/q/q.js:125:13)
      at _combinedTickCallback (internal/process/next_tick.js:131:7)
      at process._tickCallback (internal/process/next_tick.js:180:9)
      Failed to restore plugin "cordova-plugin-background-mode" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin cordova-plugin-device via registry.
      Probably this is either a connection problem, or plugin spec is incorrect.
      Check your connection and plugin name/version/URL.
      Failed to get absolute path to installed module
      Discovered plugin "cordova-plugin-device" in config.xml. Adding it to the project
      No scripts found for hook "before_plugin_add".
      Calling plugman.fetch on plugin "cordova-plugin-device@^1.1.6"
      Running command: npm install cordova-plugin-device@^1.1.6
      Command finished with error code 216: npm install,cordova-plugin-device@^1.1.6
      Failed to restore plugin "cordova-plugin-device" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin cordova-plugin-device@^1.1.6 via registry.
      Probably this is either a connection problem, or plugin spec is incorrect.
      Check your connection and plugin name/version/URL.
      Error: npm: Command failed with exit code 216 Error output:
      npm WARN checkPermissions Missing write access to /home/mhofer/hello/node_modules/cordova-plugin-device
      npm WARN com.example.hello@1.0.0 No repository field.

      npm ERR! path /home/mhofer/hello/node_modules/cordova-plugin-device
      npm ERR! code ELOOP
      npm ERR! errno -40
      npm ERR! syscall access
      npm ERR! ELOOP: too many symbolic links encountered, access '/home/mhofer/hello/node_modules/cordova-plugin-device'

      npm ERR! A complete log of this run can be found in:
      npm ERR! /home/mhofer/.npm/_logs/2017-09-21T15_28_52_386Z-debug.log
      Checking for any plugins added to the project that have not been installed in android platform
      No differences found between plugins added to project and installed in android platform. Continuing...
      Generating platform-specific config.xml from defaults for android at /home/mhofer/hello/platforms/android/res/xml/config.xml
      Merging project's config.xml into platform-specific android config.xml
      Merging and updating files from [www, platforms/android/platform_www] to platforms/android/assets/www
      mkdir platforms/android/assets/www/cordova-js-src
      mkdir platforms/android/assets/www/cordova-js-src/android
      copy platforms/android/platform_www/cordova-js-src/android/nativeapiprovider.js platforms/android/assets/www/cordova-js-src/android/nativeapiprovider.js (new file)
      copy platforms/android/platform_www/cordova-js-src/android/promptbasednativeapi.js platforms/android/assets/www/cordova-js-src/android/promptbasednativeapi.js (new file)
      copy platforms/android/platform_www/cordova-js-src/exec.js platforms/android/assets/www/cordova-js-src/exec.js (new file)
      copy platforms/android/platform_www/cordova-js-src/platform.js platforms/android/assets/www/cordova-js-src/platform.js (new file)
      mkdir platforms/android/assets/www/cordova-js-src/plugin
      mkdir platforms/android/assets/www/cordova-js-src/plugin/android
      copy platforms/android/platform_www/cordova-js-src/plugin/android/app.js platforms/android/assets/www/cordova-js-src/plugin/android/app.js (new file)
      copy platforms/android/platform_www/cordova.js platforms/android/assets/www/cordova.js (updated file)
      copy platforms/android/platform_www/cordova_plugins.js platforms/android/assets/www/cordova_plugins.js (updated file)
      delete platforms/android/assets/www/img/cordova.png (no source)
      copy www/index.html platforms/android/assets/www/index.html (updated file)
      copy www/js/index.js platforms/android/assets/www/js/index.js (updated file)
      Wrote out android application name "HelloWorld" to /home/mhofer/hello/platforms/android/res/values/strings.xml
      android-versionCode not found in config.xml. Generating a code based on version in config.xml (1.0.0): 10000
      Wrote out Android package name "com.example.hello" to /home/mhofer/hello/platforms/android/src/com/example/hello/MainActivity.java
      This app does not have launcher icons defined
      This app does not have splash screens defined
      This app does not have additional resource files defined
      Prepared android project successfully
      No scripts found for hook "after_prepare".

      Notice how the version of the device plugin has been modifed and node_modules/cordova-plugin-device is now a symlink pointing to itself:

      ✔ ~/hello
      $ cat package.json
      {
      "name": "com.example.hello",
      "displayName": "HelloWorld",
      "version": "1.0.0",
      "description": "A sample Apache Cordova application that responds to the deviceready event.",
      "main": "index.js",
      "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
      },
      "author": "Apache Cordova Team",
      "license": "Apache-2.0",
      "dependencies": {
      "cordova-android": "^6.3.0-nightly.2017.9.21.dddb2837",
      "cordova-plugin-background-mode": "^0.7.2",
      "cordova-plugin-device": "file:node_modules/cordova-plugin-device",
      "cordova-plugin-whitelist": "^1.3.2"
      },
      "cordova": {
      "plugins": {
      "cordova-plugin-whitelist": {},
      "cordova-plugin-device": {},
      "cordova-plugin-background-mode": {}
      },
      "platforms": [
      "android"
      ]
      }
      }
      ✔ ~/hello
      $ cat config.xml
      <?xml version='1.0' encoding='utf-8'?>
      <widget id="com.example.hello" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
      <name>HelloWorld</name>
      <description>
      A sample Apache Cordova application that responds to the deviceready event.
      </description>
      <author email="dev@cordova.apache.org" href="http://cordova.io">
      Apache Cordova Team
      </author>
      <content src="index.html" />
      <access origin="*" />
      <allow-intent href="http:///" />
      <allow-intent href="https:///" />
      <allow-intent href="tel:*" />
      <allow-intent href="sms:*" />
      <allow-intent href="mailto:*" />
      <allow-intent href="geo:*" />
      <platform name="android">
      <allow-intent href="market:*" />
      </platform>
      <platform name="ios">
      <allow-intent href="itms:*" />
      <allow-intent href="itms-apps:*" />
      </platform>
      <engine name="android" spec="^6.3.0-nightly.2017.9.21.dddb2837" />
      <plugin name="cordova-plugin-whitelist" spec="^1.3.2" />
      <plugin name="cordova-plugin-device" spec="^1.1.6" />
      <plugin name="cordova-plugin-background-mode" spec="^0.7.2" />
      </widget>
      ✔ ~/hello
      $ ls -ld node_modules/cordova-*
      drwxrwxr-x 9 mhofer mhofer 4096 Sep 21 17:28 node_modules/cordova-android
      drwxrwxr-x 4 mhofer mhofer 4096 Sep 21 17:28 node_modules/cordova-plugin-background-mode
      lrwxrwxrwx 1 mhofer mhofer 21 Sep 21 17:28 node_modules/cordova-plugin-device -> cordova-plugin-device
      drwxrwxr-x 5 mhofer mhofer 4096 Sep 21 17:28 node_modules/cordova-plugin-whitelist

      The same error occures, if I add the background-plugin first, then the device plugin.

      Attachments

        Activity

          People

            stevegill Steve Gill
            hupf Mathis Hofer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: