pass the value of the android sdk (#11268)

* pass the value of the android sdk

* swap flag

* allow the user to set the android-sdk location
This commit is contained in:
Devon Carew
2017-07-18 18:47:20 -07:00
committed by GitHub
parent daa7860ef0
commit c186d0df1c
5 changed files with 80 additions and 32 deletions

View File

@@ -67,7 +67,10 @@ class AndroidSdk {
static AndroidSdk locateAndroidSdk() {
String androidHomeDir;
if (platform.environment.containsKey(kAndroidHome)) {
if (config.containsKey('android-sdk')) {
androidHomeDir = config.getValue('android-sdk');
} else if (platform.environment.containsKey(kAndroidHome)) {
androidHomeDir = platform.environment[kAndroidHome];
} else if (platform.isLinux) {
if (homeDirPath != null)

View File

@@ -24,6 +24,8 @@ class Config {
Iterable<String> get keys => _values.keys;
bool containsKey(String key) => _values.containsKey(key);
dynamic getValue(String key) => _values[key];
void setValue(String key, String value) {

View File

@@ -5,6 +5,7 @@
import 'dart:async';
import 'dart:convert';
import '../android/android_sdk.dart';
import '../android/android_studio.dart';
import '../globals.dart';
import '../runner/flutter_command.dart';
@@ -19,6 +20,7 @@ class ConfigCommand extends FlutterCommand {
negatable: false,
help: 'Clear the saved development certificate choice used to sign apps for iOS device deployment.');
argParser.addOption('gradle-dir', help: 'The gradle install directory.');
argParser.addOption('android-sdk', help: 'The Android SDK directory.');
argParser.addOption('android-studio-dir', help: 'The Android Studio install directory.');
argParser.addFlag('machine',
negatable: false,
@@ -38,6 +40,9 @@ class ConfigCommand extends FlutterCommand {
@override
final List<String> aliases = <String>['configure'];
@override
bool get shouldUpdateCache => false;
@override
String get usageFooter {
// List all config settings.
@@ -69,6 +74,9 @@ class ConfigCommand extends FlutterCommand {
if (argResults.wasParsed('gradle-dir'))
_updateConfig('gradle-dir', argResults['gradle-dir']);
if (argResults.wasParsed('android-sdk'))
_updateConfig('android-sdk', argResults['android-sdk']);
if (argResults.wasParsed('android-studio-dir'))
_updateConfig('android-studio-dir', argResults['android-studio-dir']);
@@ -90,8 +98,11 @@ class ConfigCommand extends FlutterCommand {
if (results['android-studio-dir'] == null && androidStudio != null) {
results['android-studio-dir'] = androidStudio.directory;
}
if (results['android-sdk'] == null && androidSdk != null) {
results['android-sdk'] = androidSdk.directory;
}
printStatus(JSON.encode(results));
printStatus(const JsonEncoder.withIndent(' ').convert(results));
}
void _updateConfig(String keyName, String keyValue) {