Commit cd3fd475 authored by Jakob Andersen's avatar Jakob Andersen Committed by GitHub

Don't update Android SDK settings in build.gradle (#8089)

parent 0370f712
......@@ -145,16 +145,6 @@ Future<String> ensureGradlew() async {
printTrace('Using gradle from $gradle.');
}
// Stamp the android/app/build.gradle file with the current android sdk and build tools version.
File appGradleFile = fs.file('android/app/build.gradle');
if (appGradleFile.existsSync()) {
_GradleFile gradleFile = new _GradleFile.parse(appGradleFile);
AndroidSdkVersion sdkVersion = androidSdk.latestVersion;
gradleFile.replace('compileSdkVersion', "${sdkVersion.sdkLevel}");
gradleFile.replace('buildToolsVersion', "'${sdkVersion.buildToolsVersionName}'");
gradleFile.writeContents(appGradleFile);
}
// Run 'gradle wrapper'.
List<String> command = logger.isVerbose
? <String>[gradle, 'wrapper']
......@@ -255,26 +245,3 @@ Future<Null> buildGradleProjectV2(String gradlew, String buildModeName) async {
apkFile.copySync('$gradleAppOutDir/app.apk');
printStatus('Built $apkFilename (${getSizeAsMB(apkFile.lengthSync())}).');
}
class _GradleFile {
_GradleFile.parse(File file) {
contents = file.readAsStringSync();
}
String contents;
void replace(String key, String newValue) {
// Replace 'ws key ws value' with the new value.
final RegExp regex = new RegExp('\\s+$key\\s+(\\S+)', multiLine: true);
Match match = regex.firstMatch(contents);
if (match != null) {
String oldValue = match.group(1);
int offset = match.end - oldValue.length;
contents = contents.substring(0, offset) + newValue + contents.substring(match.end);
}
}
void writeContents(File file) {
file.writeAsStringSync(contents);
}
}
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