GitHub user filmaj opened a pull request:

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

    Updated CLI scripts to support Android SDK Tools 25.3.1 

    <!--
    Please make sure the checklist boxes are all checked before submitting the 
PR. The checklist
    is intended as a quick reference, for complete details please see our 
Contributor Guidelines:
    
    http://cordova.apache.org/contribute/contribute_guidelines.html
    
    Thanks!
    -->
    
    ### Platforms affected
    
    Android
    
    ### What does this PR do?
    
    Adds support for using the Android SDK Tools version 25.3.1.
    
    Relevant issues are 
[CB-12546](https://issues.apache.org/jira/browse/CB-12546) and 
[CB-12554](https://issues.apache.org/jira/browse/CB-12554).
    
    In general, the CLI scripts will now attempt to use the old tools first 
(specifically the `android` command), and if that command fails with a specific 
exit code and message (tested on Windows 10 and Mac OS 10.12), it will then try 
to use the new tools (specifically the `avdmanager` and `sdkmanager` commands).
    
    I have also renamed a bunch of methods in an attempt to try to make it 
clearer what they are doing.
    
    I have added a _bunch_ of jasmine unit tests to all of this as well. Hoping 
the coverage report reflects that!
    
    ### What testing has been done on this change?
    
    I tested on two OSes: Mac OS 10.12 and Windows 10. For each OS, I tested 
four environment setups:
    
    1. Setting `ANDROID_HOME` environment variable to point to a new 
installation of the Android SDK.
    2. Setting `PATH` environment variable to contain the `tools`, `tools/bin` 
and `platform-tools` Android SDK subdirectories.
    3. Having neither of the above environment variables set.
    4. Having both of the above environment variables set.
    
    For each environment, I then ran the following test scenarios:
    
    1. Running `npm test` from the repo. In all eight environments, this passed.
    2. Running `bin/check_reqs` from the repo. If neither environment variables 
are set, you would receive an error telling you to set `ANDROID_HOME`. In the 
other 6 cases, `check_reqs` tells you you are all good.
    3. Running `bin/android_sdk_version` from the repo. In the four 
environments I tested where you didn't have the `android` command on your 
`PATH`, you would get a "`android` cannot be found" error. In the other four, 
it would return the id of the latest android target you have installed on your 
system.
    4. Running `bin/create` from the repo. This passed in all eight 
environments.
    5. I checked running the following commands in a generated cordova-android 
project:
      - `cordova/android_sdk_version`: same behaviour as test scenario 3 above 
(as expected).
      - `cordova/check_reqs`: same behaviour as test scenario 2 above (as 
expected).
      - `cordova/build`: it would error out if you didn't have your 
`ANDROID_HOME` set and tell you to set it. Otherwise, passed fine.
      - `cordova/clean`: same as `build` above ✅ 
      - `cordova/run --emulator`: same as `build` above ✅ 
    
    **NOTE**: This has not been tested on an Android SDK installation with SDK 
Tools older than 25.3.1! I would love for someone with SDK Tools 25.2.x to give 
this a go.
    
    ### Other Notes
    
    These are extensive changes! I would love a bunch of people to review this, 
so pinging @infil00p, @purplecabbage, @shazron, @stevengill, @timkim, 
@macdonst, @dpogue. Review party!
    
    ### Checklist
    - [X] [Reported an 
issue](http://cordova.apache.org/contribute/issues.html): 
[CB-12546](https://issues.apache.org/jira/browse/CB-12546), 
[CB-12554](https://issues.apache.org/jira/browse/CB-12554)
    - [X] Commit message follows the format: "CB-3232: (android) Fix bug with 
resolving file paths", 
    - [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-12546

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

    https://github.com/apache/cordova-android/pull/369.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 #369
    
----
commit 3a1fa5d63a67ad9d32e2147d45b07c86837b36fa
Author: filmaj <maj....@gmail.com>
Date:   2017-03-08T01:04:11Z

    CB-12546: leverage `avdmanager` if `android` warns it is no longer
    useful, which happens in Android SDK Tools 25.3.1.
    explicitly set the CWD of the spawned emulator process to workaround a 
recent google android sdk bug.
    rename android_sdk_version.js to android_sdk.js, to better reflect its 
contents.
    have create.js copy over the android_sdk_version batch file.

commit 87a293b932846087abc894e6c1f66fbfed39908c
Author: filmaj <maj....@gmail.com>
Date:   2017-03-14T06:44:52Z

    CB-12546: more robust sdk location detection. ANDROID_HOME now can be set 
from location of either of `adb`, `android` or `avdmanager` commands. slightly 
rework logic of infering ANDROID_HOME + setting up PATH to hopefully separate 
the logic into clearer sections. check_reqs.check_android now validates SDK 
Tools 25.3.1 binaries/structure. added specs for check_reqs.check_android. move 
android sdk version script. expose some helper functions as module methods to 
help with mocking.

commit 661d71be4869f764d83438f2ceea6be2f4ad4a40
Author: filmaj <maj....@gmail.com>
Date:   2017-03-14T20:12:57Z

    CB-12546: emulator specs.

commit c21ff310342ef9f570949f229a94d0d229935c52
Author: filmaj <maj....@gmail.com>
Date:   2017-03-14T21:18:00Z

    CB-12546: move check_reqs to templates directory and update module 
references.

commit 9190ca9416b1e2b6704f59aece32b3a81a80a5d5
Author: filmaj <maj....@gmail.com>
Date:   2017-03-14T22:15:49Z

    CB-12546: based on `android` command exit code and stdout, conditionally 
try to invoke `avdmanager` to list out AVD images. tweak relevant test to match 
behaviour. small tweak to use exposed methods for checking platform (for easier 
future stubbing).

commit 6a0f9339690956569cff5a8ff07c1f570b5d5c77
Author: filmaj <maj....@gmail.com>
Date:   2017-03-14T23:01:32Z

    CB-12546: switch to superspawn for shelling out where possible. rework 
android sdk module to work with new sdk.

commit 182cfdebc781b9ac3f6b67c5c6bb429b78573567
Author: filmaj <maj....@gmail.com>
Date:   2017-03-14T23:18:37Z

    CB-12546: use android_sdk list_targets instead of rewriting the same thing 
again.

commit 35ea09d72185b30f17ab4b579bf615517482e883
Author: filmaj <maj....@gmail.com>
Date:   2017-03-15T14:47:51Z

    CB-12546: more specs for android_sdk and check_reqs. added fixtures for sdk 
targets. refactored target listing.

commit a1933955d9ee3d647450cb736faf947bc91679c4
Author: filmaj <maj....@gmail.com>
Date:   2017-03-15T18:30:04Z

    CB-12546: sort detected targets by numerical suffix when reporting most 
recent version of android sdk target installed.

commit 17952029cfcb80fdc24896286a5547f7b96d766c
Author: filmaj <maj....@gmail.com>
Date:   2017-03-15T18:58:16Z

    CB-12546: on create, update the require path for certain helper modules as 
directory structure differs. big ol TODO dropped as it _is_ kinda weird.

commit 389d81b972cc272b4911f0140891a5fb6c740abd
Author: filmaj <maj....@gmail.com>
Date:   2017-03-15T22:35:29Z

    CB-12546: account for quotes when detecting `android` command error for 
Windows.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@cordova.apache.org
For additional commands, e-mail: dev-h...@cordova.apache.org

Reply via email to