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 { ...@@ -49,12 +49,24 @@ class AndroidSdk {
static AndroidSdk locateAndroidSdk() { static AndroidSdk locateAndroidSdk() {
// TODO: Use explicit configuration information from a metadata file? // TODO: Use explicit configuration information from a metadata file?
String androidHomeDir;
if (Platform.environment.containsKey('ANDROID_HOME')) { if (Platform.environment.containsKey('ANDROID_HOME')) {
String homeDir = Platform.environment['ANDROID_HOME']; androidHomeDir = Platform.environment['ANDROID_HOME'];
if (validSdkDirectory(homeDir)) } else if (Platform.isLinux) {
return new AndroidSdk(homeDir); String homeDir = Platform.environment['HOME'];
if (validSdkDirectory(path.join(homeDir, 'sdk'))) if (homeDir != null)
return new AndroidSdk(path.join(homeDir, 'sdk')); 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 File aaptBin = os.which('aapt'); // in build-tools/$version/aapt
......
...@@ -177,7 +177,7 @@ class ApkCommand extends FlutterCommand { ...@@ -177,7 +177,7 @@ class ApkCommand extends FlutterCommand {
Future<int> runInProject() async { Future<int> runInProject() async {
// Validate that we can find an android sdk. // Validate that we can find an android sdk.
if (androidSdk == null) { if (androidSdk == null) {
printError('No Android SDK found.'); printError('No Android SDK found. Try setting the ANDROID_HOME environment variable.');
return 1; return 1;
} }
...@@ -371,7 +371,7 @@ Future<int> buildAndroid({ ...@@ -371,7 +371,7 @@ Future<int> buildAndroid({
}) async { }) async {
// Validate that we can find an android sdk. // Validate that we can find an android sdk.
if (androidSdk == null) { if (androidSdk == null) {
printError('No Android SDK found.'); printError('No Android SDK found. Try setting the ANDROID_HOME environment variable.');
return 1; 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