mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Don't update Android SDK settings in build.gradle (#8089)
This commit is contained in:
parent
0370f712f6
commit
cd3fd475d8
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user