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

Cordova CLI run for Android versions 4.1.1 and lower throws error

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 5.0.0
    • None
    • None
    • Cordova CLI 5.0.0
      Cordova Lib 5.0.0
      Mac Yosemite 10.10.2
      Android platform tools 22
      Android 4.1

    Description

      When running `cordova run android` and an Android v4.1 device connected, the `adb` command fails.

      You can read more about the error on the Ionic CLI issues, as ionic calls cordova: https://github.com/driftyco/ionic-cli/issues/441

      Looking at the source code, the `device.js` file will try to run this command:

      'adb install -s ' + resolvedTarget.target + ' -r -d "' + apk_path + '"'

      As you can see, it passes the -d option, which works fine for most android 4.2+ devices.

      However, when Android 4.1 is involved, this error occurs:

      ```
      BUILD SUCCESSFUL

      Total time: 2.551 secs
      Built the following apk(s):
      /Users/JoshBavari/Development/testing/s1/platforms/android/build/outputs/apk/android-debug.apk
      Using apk: /Users/JoshBavari/Development/testing/s1/platforms/android/build/outputs/apk/android-debug.apk
      Installing app on device...
      Running this command to install app to device: adb -s 192.168.56.102:5555 install -r -d "/Users/JoshBavari/Development/testing/s1/platforms/android/build/outputs/apk/android-debug.apk"
      OUTPUT: Error: Unknown option: -d
      usage: pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [FILTER]
      pm list permission-groups
      pm list permissions [-g] [-f] [-d] [-u] [GROUP]
      pm list instrumentation [-f] [TARGET-PACKAGE]
      pm list features
      pm list libraries
      pm path PACKAGE
      pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f]
      [--algo <algorithm name> --key <key-in-hex> --iv <IV-in-hex>] PATH
      pm uninstall [-k] PACKAGE
      pm clear PACKAGE
      pm enable PACKAGE_OR_COMPONENT
      pm disable PACKAGE_OR_COMPONENT
      pm disable-user PACKAGE_OR_COMPONENT
      pm grant PACKAGE PERMISSION
      pm revoke PACKAGE PERMISSION
      pm set-install-location [0/auto] [1/internal] [2/external]
      pm get-install-location
      pm set-permission-enforced PERMISSION [true|false]
      ```

      Now when I run with an Android 4.4 device attached:

      ```
      Total time: 2.585 secs
      Built the following apk(s):
      /Users/JoshBavari/Development/testing/s1/platforms/android/build/outputs/apk/android-debug.apk
      Using apk: /Users/JoshBavari/Development/testing/s1/platforms/android/build/outputs/apk/android-debug.apk
      Installing app on device...
      Running this command to install app to device: adb -s 192.168.56.101:5555 install -r -d "/Users/JoshBavari/Development/testing/s1/platforms/android/build/outputs/apk/android-debug.apk"
      OUTPUT: pkg: /data/local/tmp/android-debug.apk
      Success

      Launching application...
      LAUNCH SUCCESS
      ```

      My guess here is that this is an issue with the `adb` tool.

      Can anyone else confirm this is an issue? The adb tool does not work with `-d` on Android 4.1.

      Attachments

        Activity

          People

            bowserj Joey Robert Bowser
            jbavari Josh Bavari
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: