Support ANDROID_SDK_ROOT in addition to ANDROID_HOME (#25221)

* Fall back to ANDROID_SDK_ROOT if ANDROID_HOME is not set

And update descriptions to use the non-deprecated ANDROID_SDK_ROOT.

Fixes #15114.

* Remove trailing whitespace

* Update dev/devicelab/lib/framework/adb.dart

Co-Authored-By: DanTup <danny@tuppeny.com>

* Reformat long line
This commit is contained in:
Danny Tuppeny
2018-12-17 17:29:09 +00:00
committed by GitHub
parent f0871deb3e
commit c19142d8b7
8 changed files with 23 additions and 10 deletions

View File

@@ -21,6 +21,7 @@ import 'android_studio.dart' as android_studio;
AndroidSdk get androidSdk => context[AndroidSdk];
const String kAndroidHome = 'ANDROID_HOME';
const String kAndroidSdkRoot = 'ANDROID_SDK_ROOT';
// Android SDK layout:
@@ -243,6 +244,8 @@ class AndroidSdk {
androidHomeDir = config.getValue('android-sdk');
} else if (platform.environment.containsKey(kAndroidHome)) {
androidHomeDir = platform.environment[kAndroidHome];
} else if (platform.environment.containsKey(kAndroidSdkRoot)) {
androidHomeDir = platform.environment[kAndroidSdkRoot];
} else if (platform.isLinux) {
if (homeDirPath != null)
androidHomeDir = fs.path.join(homeDirPath, 'Android', 'Sdk');

View File

@@ -125,6 +125,10 @@ class AndroidValidator extends DoctorValidator {
final String androidHomeDir = platform.environment[kAndroidHome];
messages.add(ValidationMessage('$kAndroidHome = $androidHomeDir'));
}
if (platform.environment.containsKey(kAndroidSdkRoot)) {
final String androidSdkRoot = platform.environment[kAndroidSdkRoot];
messages.add(ValidationMessage('$kAndroidSdkRoot = $androidSdkRoot'));
}
final List<String> validationResult = androidSdk.validateSdkWellFormed();

View File

@@ -30,7 +30,7 @@ Future<void> buildApk({
// Validate that we can find an android sdk.
if (androidSdk == null)
throwToolExit('No Android SDK found. Try setting the ANDROID_HOME environment variable.');
throwToolExit('No Android SDK found. Try setting the ANDROID_SDK_ROOT environment variable.');
final List<String> validationResult = androidSdk.validateSdkWellFormed();
if (validationResult.isNotEmpty) {