Commit db729420 authored by Adam Barth's avatar Adam Barth

Merge pull request #1940 from abarth/improve_android_sdk

Improve error message when Android SDK not found
parents 99876e38 bef8d081
......@@ -49,12 +49,24 @@ class AndroidSdk {
static AndroidSdk locateAndroidSdk() {
// TODO: Use explicit configuration information from a metadata file?
String androidHomeDir;
if (Platform.environment.containsKey('ANDROID_HOME')) {
String homeDir = Platform.environment['ANDROID_HOME'];
if (validSdkDirectory(homeDir))
return new AndroidSdk(homeDir);
if (validSdkDirectory(path.join(homeDir, 'sdk')))
return new AndroidSdk(path.join(homeDir, 'sdk'));
androidHomeDir = Platform.environment['ANDROID_HOME'];
} else if (Platform.isLinux) {
String homeDir = Platform.environment['HOME'];
if (homeDir != null)
androidHomeDir = '$homeDir/Android/Sdk';
} else if (Platform.isMacOS) {
String homeDir = Platform.environment['HOME'];
if (homeDir != null)
androidHomeDir = '$homeDir/Library/Android/sdk';
}
if (androidHomeDir != null) {
if (validSdkDirectory(androidHomeDir))
return new AndroidSdk(androidHomeDir);
if (validSdkDirectory(path.join(androidHomeDir, 'sdk')))
return new AndroidSdk(path.join(androidHomeDir, 'sdk'));
}
File aaptBin = os.which('aapt'); // in build-tools/$version/aapt
......
......@@ -177,7 +177,7 @@ class ApkCommand extends FlutterCommand {
Future<int> runInProject() async {
// Validate that we can find an android sdk.
if (androidSdk == null) {
printError('No Android SDK found.');
printError('No Android SDK found. Try setting the ANDROID_HOME environment variable.');
return 1;
}
......@@ -371,7 +371,7 @@ Future<int> buildAndroid({
}) async {
// Validate that we can find an android sdk.
if (androidSdk == null) {
printError('No Android SDK found.');
printError('No Android SDK found. Try setting the ANDROID_HOME environment variable.');
return 1;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment