Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ANDROID_SDK_ROOT variable #951

Merged
merged 1 commit into from
Apr 16, 2020

Conversation

breautek
Copy link
Contributor

@breautek breautek commented Apr 12, 2020

Platforms affected

Android

Motivation and Context

Fixes #949 which describes a functional issue
Fixes #670 which describes a cosmetic issue that is loosely related.

Description

This PR depends on two other PRs: #959 #960

This PR does the following:

  • Makes ANDROID_SDK_ROOT the primary variable to look for the Android SDK location.
  • Makes ANDROID_HOME the fallback variable, if ANDROID_SDK_ROOT is not present/valid.

Gradle updates:
Note that the following gradle updates were required, otherwise the android gradle plugin did not honour the ANDROID_SDK_ROOT variable.

  • Updates the framework's android studio's gradle plugin from version 3.3.0 to 3.5.3.
    Not only this is required for android's gradle to obey ANDROID_SDK_ROOT, it is now in sync with the Android test project/
  • Updates the Androidx test project to use gralde plugin from version 3.3.0 to 3.5.3, to match Android Test & framework.
    • Consequentially, this required to also upgrade AndroidX test project to use Gradle 6.1, which also matches both the Android test project & framework

Gradle updates have been moved to independent PRs #959 #960

These changes above fixes #949

Additionally, since we update the environment variables dynamically, the environment variable printout produced misleading information.
The environment variable printout will now print out the variable as defined by the user (before the tooling messes with them). An additional log
is printed that tells the user exactly what Cordova is going to use for the Android SDK path. This should fix #670

Tests was also changed to mainly use ANDROID_SDK_ROOT instead of ANDROID_HOME. Additional tests were added to ensure things works with either variable, but ANDROID_SDK_ROOT now takes precedence over ANDROID_HOME, should both be defined.

Testing

npm test passes successfully, both old and new.
I've ran npm test in every combination of:

  • with ANDROID_SDK_ROOT / with ANDROID_HOME
  • with ANDROID_SDK_ROOT / without ANDROID_HOME
  • without ANDROID_SDK_ROOT / with ANDROID_HOME
  • without ANDROID_SDK_ROOT / without ANDROID_HOME

Additionally, I've tested each of these combinations with a hello world cordova test app, to ensure build runs successfully.

This PR should be accompanied with a cordova-docs PR to update the Environment Variables documentation, which has not been done yet.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@breautek breautek changed the title fix: ANDROID_SDK_ROOT variable WIP: fix: ANDROID_SDK_ROOT variable Apr 12, 2020
@breautek
Copy link
Contributor Author

Not sure why it's failling on mac, NodeJS on mac must behaves slightly different, will investigate tomorrow.

Also pondering forcing ANDROID_HOME from the environment after a correct sdk path is determined considering...

If ANDROID_HOME is defined and contains a valid SDK installation, its value is used instead of the value in ANDROID_SDK_ROOT.

https://developer.android.com/studio/command-line/variables#android_sdk_root

@codecov-io
Copy link

Codecov Report

Merging #951 into master will increase coverage by 0.56%.
The diff coverage is 86.84%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #951      +/-   ##
==========================================
+ Coverage   65.53%   66.10%   +0.56%     
==========================================
  Files          21       21              
  Lines        1828     1838      +10     
==========================================
+ Hits         1198     1215      +17     
+ Misses        630      623       -7     
Impacted Files Coverage Δ
bin/templates/cordova/lib/check_reqs.js 57.60% <86.84%> (+5.42%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6402e7b...7634087. Read the comment docs.

@breautek breautek marked this pull request as ready for review April 13, 2020 18:49
@breautek breautek changed the title WIP: fix: ANDROID_SDK_ROOT variable fix: ANDROID_SDK_ROOT variable Apr 13, 2020
Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Rebase PR
    • Re-run the lint after rebasing. I believe there are some cases that will be caught with the new lint version.
  • Revert all gradle changes and move those changes into its own PR

@breautek breautek force-pushed the fix/android-sdk-root-env branch 2 times, most recently from 2b009d8 to c715ca4 Compare April 15, 2020 23:43
@breautek breautek changed the title fix: ANDROID_SDK_ROOT variable WIP: fix: ANDROID_SDK_ROOT variable Apr 15, 2020
@breautek
Copy link
Contributor Author

Putting this PR back to "WIP" since the latest rebase, this branch specifically does not pass a test for some reason... the test that is failing seems unrelated, so will need to investigate...

Oddly enough, it doesn't fail in the other 2 branches that this PR depends on, so it is something specific to this branch.

This commit does the following:
- Makes ANDROID_SDK_ROOT the primary variable to look for the Android SDK location.
- Makes ANDROID_HOME the fallback variable, if ANDROID_SDK_ROOT is not present/valid.

Gradle updates:
Note that the following gradle updates were required, otherwise the android gradle plugin did not honour the ANDROID_SDK_ROOT variable.

- Updates the framework's android studio's gradle plugin from version 3.3.0 to 3.5.3.
	Not only this is required for android's gradle to obey ANDROID_SDK_ROOT, it is now in sync with the Android test project/
- Updates the Androidx test project to use gralde plugin from version 3.3.0 to 3.5.3, to match Android Test & framework.
	- Consequentially, this required to also upgrade AndroidX test project to use Gradle 6.1, which also matches both the Android test project & framework

These changes above fixes apache#949

Additionally, since we update the environment variables dynamically, the environment variable printout produced misleading information.
The environment variable printout will now print out the variable as defined by the user (before the tooling messes with them). An additional log
is printed that tells the user exactly what Cordova is going to use for the Android SDK path. This should fix apache#670
@breautek breautek changed the title WIP: fix: ANDROID_SDK_ROOT variable fix: ANDROID_SDK_ROOT variable Apr 16, 2020
@breautek breautek requested review from erisu and janpio April 16, 2020 00:22
@breautek breautek closed this Apr 16, 2020
@breautek breautek reopened this Apr 16, 2020
@breautek breautek merged commit 16a88ec into apache:master Apr 16, 2020
@breautek breautek deleted the fix/android-sdk-root-env branch April 16, 2020 02:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants