Commit fc0b18c7 authored by Devon Carew's avatar Devon Carew

update the min api level in the generated android manifest; use constants for...

update the min api level in the generated android manifest; use constants for the android version name
parent 29ab6efd
......@@ -12,6 +12,7 @@ import 'package:path/path.dart' as path;
import '../artifacts.dart';
import '../base/logging.dart';
import '../base/process.dart';
import '../device.dart';
class InitCommand extends Command {
final String name = 'init';
......@@ -121,7 +122,11 @@ abstract class Template {
String relativeFlutterPackagePath = path.relative(flutterPackagePath, from: dirPath);
files.forEach((String filePath, String contents) {
Map m = {'projectName': projectName, 'description': description, 'flutterPackagePath': relativeFlutterPackagePath};
Map m = {
'projectName': projectName,
'description': description,
'flutterPackagePath': relativeFlutterPackagePath
};
contents = mustache.render(contents, m);
filePath = filePath.replaceAll('/', Platform.pathSeparator);
File file = new File(path.join(dir.path, filePath));
......@@ -223,11 +228,11 @@ class FlutterDemo extends StatelessComponent {
}
''';
const String _apkManifest = r'''
final String _apkManifest = '''
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.{{projectName}}">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
<uses-sdk android:minSdkVersion="${AndroidDevice.minApiLevel}" android:targetSdkVersion="21" />
<uses-permission android:name="android.permission.INTERNET"/>
<application android:name="org.domokit.sky.shell.SkyApplication" android:label="{{projectName}}">
......
......@@ -474,7 +474,11 @@ class IOSSimulator extends Device {
}
class AndroidDevice extends Device {
static const String _ADB_PATH = 'adb';
static const int minApiLevel = 16;
static const String minVersionName = 'Jelly Bean';
static const String minVersionText = '4.1.x';
static const String _defaultAdbPath = 'adb';
static const int _observatoryPort = 8181;
static final String defaultDeviceID = 'default_android_device';
......@@ -574,7 +578,7 @@ class AndroidDevice extends Device {
_adbPath = _getAdbPath();
_hasAdb = _checkForAdb();
// Checking for Jelly Bean only needs to be done if we are starting an
// Checking for [minApiName] only needs to be done if we are starting an
// app, but it has an important side effect, which is to discard any
// progress messages if the adb server is restarted.
_hasValidAndroid = _checkForSupportedAndroidVersion();
......@@ -606,8 +610,7 @@ class AndroidDevice extends Device {
static String _getAdbPath() {
if (Platform.environment.containsKey('ANDROID_HOME')) {
String androidHomeDir = Platform.environment['ANDROID_HOME'];
String adbPath1 =
path.join(androidHomeDir, 'sdk', 'platform-tools', 'adb');
String adbPath1 = path.join(androidHomeDir, 'sdk', 'platform-tools', 'adb');
String adbPath2 = path.join(androidHomeDir, 'platform-tools', 'adb');
if (FileSystemEntity.isFileSync(adbPath1)) {
return adbPath1;
......@@ -615,11 +618,11 @@ class AndroidDevice extends Device {
return adbPath2;
} else {
logging.info('"adb" not found at\n "$adbPath1" or\n "$adbPath2"\n' +
'using default path "$_ADB_PATH"');
return _ADB_PATH;
'using default path "$_defaultAdbPath"');
return _defaultAdbPath;
}
} else {
return _ADB_PATH;
return _defaultAdbPath;
}
}
......@@ -703,9 +706,10 @@ class AndroidDevice extends Device {
logging.severe('Unexpected response from getprop: "$sdkVersion"');
return false;
}
if (sdkVersionParsed < 16) {
logging.severe('The Android version ($sdkVersion) on the target device '
'is too old. Please use a Jelly Bean (version 16 / 4.1.x) device or later.');
if (sdkVersionParsed < minApiLevel) {
logging.severe(
'The Android version ($sdkVersion) on the target device is too old. Please '
'use a $minVersionName (version $minApiLevel / $minVersionText) device or later.');
return false;
}
return true;
......@@ -735,8 +739,7 @@ class AndroidDevice extends Device {
if (!isConnected()) {
return false;
}
if (runCheckedSync(adbCommandForDevice(['shell', 'pm', 'path', app.id])) ==
'') {
if (runCheckedSync(adbCommandForDevice(['shell', 'pm', 'path', app.id])) == '') {
logging.info(
'TODO(iansf): move this log to the caller. ${app.name} is not on the device. Installing now...');
return false;
......
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