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

listing targets with cli scripts does not work with v26 of android sdk tools

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 6.2.1
    • Fix Version/s: None
    • Component/s: cordova-android
    • Labels:
      None

      Description

      Another Android SDK Tools release, another new problem! The android command is back and has completely different behaviour from SDK Tools 25.3.x. It now:
      a) prints out a deprecation warning
      b) does not accept list targets (must be list target) as a command
      c) does not print out an error message telling users to use avdmanager or sdkmanager

      In 25.3.x, android would exit with a non-zero exit code and print out an error message saying the command is no longer available.

      In 25.2.x and below, android was the go-to command for all things android-related.

      The existing code for listing targets currently follows this flow:
      1. Run android to list targets. If that works, parse targets out and exit.
      2. If android fails with a non-zero exit code and a particular error message (the one that would be output in 25.3.x version of the tools), leverage sdkmanager, parse its output for installed targets.

      Joe Bowser brought up a good point to just use avdmanager list target instead of sdkmanager - it maintains the same output format for target listing as the old android tool does, which should allow us to remove the code we have in place to convert sdkmanager output to the old android output format.

      Another solid Joe Bowser piece of advice is to try to use the avdmanager tool first before falling back to android.

      I will attempt to implement both suggestions above, and add test cases leveraging output fixtures from the various Android SDK Tool versions.

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user filmaj opened a pull request:

          https://github.com/apache/cordova-android/pull/373

          Support for SDK Tools v26, simplified target parsing and preference for using newer `sdkmanager` and `avdmanager` commands

          Please review and test @infil00p, @dpogue, @shazron.

              1. Platforms affected

          Android

              1. What does this PR do?
          • Adds support for SDK Tools v26.
          • For android target parsing, now prioritizes using `avdmanager` over `android`. Also ensures that, when using `android`, to always use the singular form of the command (`android list target`), as the plural form got silently removed by Google.
          • For AVD parsing, now prioritizes using `avdmanager` over `android`. Also ensures that, when using `android`, to always use the singular form of the command (`android list avd`), as the plural form got silently removed by Google.
              1. What testing has been done on this change?

          Updated specs, also tested the following scenario:
          ```
          $ ./bin/create ../myproj
          $ cd ../myproj
          $ ./cordova/run --emulate
          ```
          .. on the following platforms:

          • Mac OS 10.12 with Android SDK Tools v26.
          • Windows 10 with Android SDK Tools v25.3.1.
          • Windows 10 with Android SDK Tools v26.

          Worked for me.

              1. Checklist
          • [x] Issue filed: CB-12640(https://issues.apache.org/jira/browse/CB-12640)
          • [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected.
          • [x] Added automated test coverage as appropriate for this change.

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/filmaj/cordova-android CB-12640

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/cordova-android/pull/373.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #373


          commit f8e4f92970d1f262baf607210febd448278b28c6
          Author: filmaj <maj.fil@gmail.com>
          Date: 2017-04-06T20:13:38Z

          CB-12640: support for android sdk tools 26.0.1. simplified target parsing by using avdmanager instead of sdkmanager. flipped target parsing logic so that it always tries to use avdmanager to retrieve targets first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests.

          commit 4995b89025b9802f1f7f5417df2e152794fd6ff5
          Author: filmaj <maj.fil@gmail.com>
          Date: 2017-04-06T20:48:58Z

          CB-12640: flipped avd parsing logic so that it always tries to use avdmanager to retrieve avds first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests - and added explicit tests to ensure to shell out to singular forms of sub-commands when executing `android`


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user filmaj opened a pull request: https://github.com/apache/cordova-android/pull/373 Support for SDK Tools v26, simplified target parsing and preference for using newer `sdkmanager` and `avdmanager` commands Please review and test @infil00p, @dpogue, @shazron. Platforms affected Android What does this PR do? Adds support for SDK Tools v26. For android target parsing, now prioritizes using `avdmanager` over `android`. Also ensures that, when using `android`, to always use the singular form of the command (`android list target`), as the plural form got silently removed by Google. For AVD parsing, now prioritizes using `avdmanager` over `android`. Also ensures that, when using `android`, to always use the singular form of the command (`android list avd`), as the plural form got silently removed by Google. What testing has been done on this change? Updated specs, also tested the following scenario: ``` $ ./bin/create ../myproj $ cd ../myproj $ ./cordova/run --emulate ``` .. on the following platforms: Mac OS 10.12 with Android SDK Tools v26. Windows 10 with Android SDK Tools v25.3.1. Windows 10 with Android SDK Tools v26. Worked for me. Checklist [x] Issue filed: CB-12640 ( https://issues.apache.org/jira/browse/CB-12640 ) [x] Commit message follows the format: "CB-3232: (android) Fix bug with resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform affected. [x] Added automated test coverage as appropriate for this change. You can merge this pull request into a Git repository by running: $ git pull https://github.com/filmaj/cordova-android CB-12640 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cordova-android/pull/373.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #373 commit f8e4f92970d1f262baf607210febd448278b28c6 Author: filmaj <maj.fil@gmail.com> Date: 2017-04-06T20:13:38Z CB-12640 : support for android sdk tools 26.0.1. simplified target parsing by using avdmanager instead of sdkmanager. flipped target parsing logic so that it always tries to use avdmanager to retrieve targets first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests. commit 4995b89025b9802f1f7f5417df2e152794fd6ff5 Author: filmaj <maj.fil@gmail.com> Date: 2017-04-06T20:48:58Z CB-12640 : flipped avd parsing logic so that it always tries to use avdmanager to retrieve avds first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests - and added explicit tests to ensure to shell out to singular forms of sub-commands when executing `android`
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 765c4ee9f691445d0b437c5ff838c3ecb57e0e85 in cordova-android's branch refs/heads/master from filmaj
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=765c4ee ]

          CB-12640: support for android sdk tools 26.0.1. simplified target parsing by using avdmanager instead of sdkmanager. flipped target parsing logic so that it always tries to use avdmanager to retrieve targets first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests.

          Show
          jira-bot ASF subversion and git services added a comment - Commit 765c4ee9f691445d0b437c5ff838c3ecb57e0e85 in cordova-android's branch refs/heads/master from filmaj [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=765c4ee ] CB-12640 : support for android sdk tools 26.0.1. simplified target parsing by using avdmanager instead of sdkmanager. flipped target parsing logic so that it always tries to use avdmanager to retrieve targets first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 6ef2f67ae88487544b983e705da1c2d82e2e79cd in cordova-android's branch refs/heads/master from filmaj
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=6ef2f67 ]

          CB-12640: flipped avd parsing logic so that it always tries to use avdmanager to retrieve avds first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests - and added explicit tests to ensure to shell out to singular forms of sub-commands when executing `android`

          Show
          jira-bot ASF subversion and git services added a comment - Commit 6ef2f67ae88487544b983e705da1c2d82e2e79cd in cordova-android's branch refs/heads/master from filmaj [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=6ef2f67 ] CB-12640 : flipped avd parsing logic so that it always tries to use avdmanager to retrieve avds first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests - and added explicit tests to ensure to shell out to singular forms of sub-commands when executing `android`
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit e13e15d3e9aa4b9a61c6ece434e7c023fa5c3553 in cordova-android's branch refs/heads/master from filmaj
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=e13e15d ]

          CB-12640: better handling of unrecognized commands on windows. removed error checking in emulator image listing when shelling out, as we already defensively dont shell out if the program is not on the PATH / not recognized. added additional test for windows unrecognized command errors for target listing. fixed up spying in a test.

          Show
          jira-bot ASF subversion and git services added a comment - Commit e13e15d3e9aa4b9a61c6ece434e7c023fa5c3553 in cordova-android's branch refs/heads/master from filmaj [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=e13e15d ] CB-12640 : better handling of unrecognized commands on windows. removed error checking in emulator image listing when shelling out, as we already defensively dont shell out if the program is not on the PATH / not recognized. added additional test for windows unrecognized command errors for target listing. fixed up spying in a test.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user filmaj closed the pull request at:

          https://github.com/apache/cordova-android/pull/373

          Show
          githubbot ASF GitHub Bot added a comment - Github user filmaj closed the pull request at: https://github.com/apache/cordova-android/pull/373
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit 46e47a3c5cc0c7f36538e7a092fd4d079aa1996d in cordova-android's branch refs/heads/6.2.x from filmaj
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=46e47a3 ]

          CB-12640: support for android sdk tools 26.0.1. simplified target parsing by using avdmanager instead of sdkmanager. flipped target parsing logic so that it always tries to use avdmanager to retrieve targets first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests.

          Show
          jira-bot ASF subversion and git services added a comment - Commit 46e47a3c5cc0c7f36538e7a092fd4d079aa1996d in cordova-android's branch refs/heads/6.2.x from filmaj [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=46e47a3 ] CB-12640 : support for android sdk tools 26.0.1. simplified target parsing by using avdmanager instead of sdkmanager. flipped target parsing logic so that it always tries to use avdmanager to retrieve targets first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests.
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit bd94735ba2663da0ff581f6b548e6821f2c17646 in cordova-android's branch refs/heads/6.2.x from filmaj
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=bd94735 ]

          CB-12640: flipped avd parsing logic so that it always tries to use avdmanager to retrieve avds first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests - and added explicit tests to ensure to shell out to singular forms of sub-commands when executing `android`

          Show
          jira-bot ASF subversion and git services added a comment - Commit bd94735ba2663da0ff581f6b548e6821f2c17646 in cordova-android's branch refs/heads/6.2.x from filmaj [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=bd94735 ] CB-12640 : flipped avd parsing logic so that it always tries to use avdmanager to retrieve avds first, then falls back to android command if avdmanager cannot be found (and errors with ENOENT). updated tests - and added explicit tests to ensure to shell out to singular forms of sub-commands when executing `android`
          Hide
          jira-bot ASF subversion and git services added a comment -

          Commit af31c83ec1c0b4b6b13049e0c99a260bbe5139c0 in cordova-android's branch refs/heads/6.2.x from filmaj
          [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=af31c83 ]

          CB-12640: better handling of unrecognized commands on windows. removed error checking in emulator image listing when shelling out, as we already defensively dont shell out if the program is not on the PATH / not recognized. added additional test for windows unrecognized command errors for target listing. fixed up spying in a test.

          Show
          jira-bot ASF subversion and git services added a comment - Commit af31c83ec1c0b4b6b13049e0c99a260bbe5139c0 in cordova-android's branch refs/heads/6.2.x from filmaj [ https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;h=af31c83 ] CB-12640 : better handling of unrecognized commands on windows. removed error checking in emulator image listing when shelling out, as we already defensively dont shell out if the program is not on the PATH / not recognized. added additional test for windows unrecognized command errors for target listing. fixed up spying in a test.
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user fredgalvao commented on a diff in the pull request:

          https://github.com/apache/cordova-docs/pull/702#discussion_r114470167

          — Diff: www/_posts/2017-05-04-android-release.md —
          @@ -0,0 +1,33 @@
          +---
          +layout: post
          +author:
          + name: Fil Maj
          + url: https://twitter.com/filmaj
          +title: "Cordova Android 6.2.3 Released!"
          +categories: announcements
          +tags: news releases
          +---
          +
          +We are happy to announce that `Cordova Android 6.2.3` has been released! This patch release actually adds support for the Android SDK Tools v26 and newer. Unfortunately, we forgot to include these changes in the 6.2.2 release.
          +
          +We strongly recommend upgrading to this version if you are using the latest Android SDK Tools. Older versions of `cordova-android` do not work with the latest Android SDK Tools!
          +
          +To upgrade:
          +
          + npm install -g cordova
          + cd my_project
          + cordova platform update android@6.2.3
          +
          +To add it explicitly:
          +
          + cordova platform add android@6.2.3
          +
          +This release will have to be explicitly added until the upcoming `cordova@7` release, where it will be pinned as the default android platform.
          +
          +<!-more->
          +## What's new in Android
          +
          +* CB-12640(https://issues.apache.org/jira/browse/CB-12640) better handling of unrecognized commands on *windows*.
          +* CB-12640(https://issues.apache.org/jira/browse/CB-12640) flipped avd parsing logic so that it always tries to use `avdmanager` to retrieve avds first, then falls back to `android` command if `avdmanager` cannot be found.
          +* CB-12640(https://issues.apache.org/jira/browse/CB-12640) support for `android sdk tools 26.0.1`.
          — End diff –

          Is it expected for all three of these links to be the same?

          Show
          githubbot ASF GitHub Bot added a comment - Github user fredgalvao commented on a diff in the pull request: https://github.com/apache/cordova-docs/pull/702#discussion_r114470167 — Diff: www/_posts/2017-05-04-android-release.md — @@ -0,0 +1,33 @@ +--- +layout: post +author: + name: Fil Maj + url: https://twitter.com/filmaj +title: "Cordova Android 6.2.3 Released!" +categories: announcements +tags: news releases +--- + +We are happy to announce that `Cordova Android 6.2.3` has been released! This patch release actually adds support for the Android SDK Tools v26 and newer. Unfortunately, we forgot to include these changes in the 6.2.2 release. + +We strongly recommend upgrading to this version if you are using the latest Android SDK Tools. Older versions of `cordova-android` do not work with the latest Android SDK Tools! + +To upgrade: + + npm install -g cordova + cd my_project + cordova platform update android@6.2.3 + +To add it explicitly: + + cordova platform add android@6.2.3 + +This release will have to be explicitly added until the upcoming `cordova@7` release, where it will be pinned as the default android platform. + +<!- more -> +## What's new in Android + +* CB-12640 ( https://issues.apache.org/jira/browse/CB-12640 ) better handling of unrecognized commands on * windows *. +* CB-12640 ( https://issues.apache.org/jira/browse/CB-12640 ) flipped avd parsing logic so that it always tries to use `avdmanager` to retrieve avds first, then falls back to `android` command if `avdmanager` cannot be found. +* CB-12640 ( https://issues.apache.org/jira/browse/CB-12640 ) support for `android sdk tools 26.0.1`. — End diff – Is it expected for all three of these links to be the same?
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user filmaj commented on a diff in the pull request:

          https://github.com/apache/cordova-docs/pull/702#discussion_r114596312

          — Diff: www/_posts/2017-05-04-android-release.md —
          @@ -0,0 +1,33 @@
          +---
          +layout: post
          +author:
          + name: Fil Maj
          + url: https://twitter.com/filmaj
          +title: "Cordova Android 6.2.3 Released!"
          +categories: announcements
          +tags: news releases
          +---
          +
          +We are happy to announce that `Cordova Android 6.2.3` has been released! This patch release actually adds support for the Android SDK Tools v26 and newer. Unfortunately, we forgot to include these changes in the 6.2.2 release.
          +
          +We strongly recommend upgrading to this version if you are using the latest Android SDK Tools. Older versions of `cordova-android` do not work with the latest Android SDK Tools!
          +
          +To upgrade:
          +
          + npm install -g cordova
          + cd my_project
          + cordova platform update android@6.2.3
          +
          +To add it explicitly:
          +
          + cordova platform add android@6.2.3
          +
          +This release will have to be explicitly added until the upcoming `cordova@7` release, where it will be pinned as the default android platform.
          +
          +<!-more->
          +## What's new in Android
          +
          +* CB-12640(https://issues.apache.org/jira/browse/CB-12640) better handling of unrecognized commands on *windows*.
          +* CB-12640(https://issues.apache.org/jira/browse/CB-12640) flipped avd parsing logic so that it always tries to use `avdmanager` to retrieve avds first, then falls back to `android` command if `avdmanager` cannot be found.
          +* CB-12640(https://issues.apache.org/jira/browse/CB-12640) support for `android sdk tools 26.0.1`.
          — End diff –

          You're right, kinda weird. I will condense down to one. These were atomic commits in the history, but for a changelog it's better to combine.

          Show
          githubbot ASF GitHub Bot added a comment - Github user filmaj commented on a diff in the pull request: https://github.com/apache/cordova-docs/pull/702#discussion_r114596312 — Diff: www/_posts/2017-05-04-android-release.md — @@ -0,0 +1,33 @@ +--- +layout: post +author: + name: Fil Maj + url: https://twitter.com/filmaj +title: "Cordova Android 6.2.3 Released!" +categories: announcements +tags: news releases +--- + +We are happy to announce that `Cordova Android 6.2.3` has been released! This patch release actually adds support for the Android SDK Tools v26 and newer. Unfortunately, we forgot to include these changes in the 6.2.2 release. + +We strongly recommend upgrading to this version if you are using the latest Android SDK Tools. Older versions of `cordova-android` do not work with the latest Android SDK Tools! + +To upgrade: + + npm install -g cordova + cd my_project + cordova platform update android@6.2.3 + +To add it explicitly: + + cordova platform add android@6.2.3 + +This release will have to be explicitly added until the upcoming `cordova@7` release, where it will be pinned as the default android platform. + +<!- more -> +## What's new in Android + +* CB-12640 ( https://issues.apache.org/jira/browse/CB-12640 ) better handling of unrecognized commands on * windows *. +* CB-12640 ( https://issues.apache.org/jira/browse/CB-12640 ) flipped avd parsing logic so that it always tries to use `avdmanager` to retrieve avds first, then falls back to `android` command if `avdmanager` cannot be found. +* CB-12640 ( https://issues.apache.org/jira/browse/CB-12640 ) support for `android sdk tools 26.0.1`. — End diff – You're right, kinda weird. I will condense down to one. These were atomic commits in the history, but for a changelog it's better to combine.

            People

            • Assignee:
              filmaj Filip Maj
              Reporter:
              filmaj Filip Maj
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development