mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Upgrade Gradle and AGP versions to 7.5/7.2 and migrate examples/tests (#108197)
This commit is contained in:
parent
b3814c7ff0
commit
ca6cecf034
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.0.0'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:4.1.3'
|
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ import 'android_sdk.dart';
|
|||||||
// For more information about the latest version, check:
|
// For more information about the latest version, check:
|
||||||
// https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
|
// https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
|
||||||
// https://kotlinlang.org/docs/gradle.html#plugin-and-versions
|
// https://kotlinlang.org/docs/gradle.html#plugin-and-versions
|
||||||
const String templateDefaultGradleVersion = '7.4';
|
const String templateDefaultGradleVersion = '7.5';
|
||||||
const String templateAndroidGradlePluginVersion = '7.1.2';
|
const String templateAndroidGradlePluginVersion = '7.2.0';
|
||||||
const String templateDefaultGradleVersionForModule = '7.1.2';
|
const String templateDefaultGradleVersionForModule = '7.2.0';
|
||||||
const String templateKotlinGradlePluginVersion = '1.6.10';
|
const String templateKotlinGradlePluginVersion = '1.7.10';
|
||||||
|
|
||||||
// These versions should match the values in flutter.gradle (FlutterExtension).
|
// These versions should match the values in flutter.gradle (FlutterExtension).
|
||||||
// The Flutter Gradle plugin is only applied to app projects, and modules that are built from source
|
// The Flutter Gradle plugin is only applied to app projects, and modules that are built from source
|
||||||
@ -204,8 +204,8 @@ String getGradleVersionFor(String androidPluginVersion) {
|
|||||||
if (_isWithinVersionRange(androidPluginVersion, min: '4.0.0', max: '4.1.0')) {
|
if (_isWithinVersionRange(androidPluginVersion, min: '4.0.0', max: '4.1.0')) {
|
||||||
return '6.7';
|
return '6.7';
|
||||||
}
|
}
|
||||||
if (_isWithinVersionRange(androidPluginVersion, min: '7.0', max: '7.4')) {
|
if (_isWithinVersionRange(androidPluginVersion, min: '7.0', max: '7.5')) {
|
||||||
return '7.4';
|
return '7.5';
|
||||||
}
|
}
|
||||||
throwToolExit('Unsupported Android Plugin version: $androidPluginVersion.');
|
throwToolExit('Unsupported Android Plugin version: $androidPluginVersion.');
|
||||||
}
|
}
|
||||||
|
@ -907,10 +907,10 @@ A problem occurred evaluating project ':app'.
|
|||||||
'│ To fix this issue, replace the following content: │\n'
|
'│ To fix this issue, replace the following content: │\n'
|
||||||
'│ /android/build.gradle: │\n'
|
'│ /android/build.gradle: │\n'
|
||||||
"│ - classpath 'com.android.tools.build:gradle:<current-version>' │\n"
|
"│ - classpath 'com.android.tools.build:gradle:<current-version>' │\n"
|
||||||
"│ + classpath 'com.android.tools.build:gradle:7.1.2' │\n"
|
"│ + classpath 'com.android.tools.build:gradle:7.2.0' │\n"
|
||||||
'│ /android/gradle/wrapper/gradle-wrapper.properties: │\n'
|
'│ /android/gradle/wrapper/gradle-wrapper.properties: │\n'
|
||||||
'│ - https://services.gradle.org/distributions/gradle-<current-version>-all.zip │\n'
|
'│ - https://services.gradle.org/distributions/gradle-<current-version>-all.zip │\n'
|
||||||
'│ + https://services.gradle.org/distributions/gradle-7.4-all.zip │\n'
|
'│ + https://services.gradle.org/distributions/gradle-7.5-all.zip │\n'
|
||||||
'└──────────────────────────────────────────────────────────────────────────────────┘\n'
|
'└──────────────────────────────────────────────────────────────────────────────────┘\n'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -357,7 +357,7 @@ void main() {
|
|||||||
'gradle',
|
'gradle',
|
||||||
label: 'gradle-expected-file-not-found',
|
label: 'gradle-expected-file-not-found',
|
||||||
parameters: CustomDimensions.fromMap(<String, String> {
|
parameters: CustomDimensions.fromMap(<String, String> {
|
||||||
'cd37': 'androidGradlePluginVersion: 7.4, fileExtension: .aab',
|
'cd37': 'androidGradlePluginVersion: 7.5, fileExtension: .aab',
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
@ -443,9 +443,9 @@ flutter:
|
|||||||
expect(getGradleVersionFor('4.0.0'), '6.7');
|
expect(getGradleVersionFor('4.0.0'), '6.7');
|
||||||
expect(getGradleVersionFor('4.1.0'), '6.7');
|
expect(getGradleVersionFor('4.1.0'), '6.7');
|
||||||
|
|
||||||
expect(getGradleVersionFor('7.0'), '7.4');
|
expect(getGradleVersionFor('7.0'), '7.5');
|
||||||
expect(getGradleVersionFor('7.1.2'), '7.4');
|
expect(getGradleVersionFor('7.1.2'), '7.5');
|
||||||
expect(getGradleVersionFor('7.2'), '7.4');
|
expect(getGradleVersionFor('7.2'), '7.5');
|
||||||
});
|
});
|
||||||
|
|
||||||
testWithoutContext('throws on unsupported versions', () {
|
testWithoutContext('throws on unsupported versions', () {
|
||||||
|
@ -73,7 +73,7 @@ void main() {
|
|||||||
'distributionPath=wrapper/dists\n'
|
'distributionPath=wrapper/dists\n'
|
||||||
'zipStoreBase=GRADLE_USER_HOME\n'
|
'zipStoreBase=GRADLE_USER_HOME\n'
|
||||||
'zipStorePath=wrapper/dists\n'
|
'zipStorePath=wrapper/dists\n'
|
||||||
'distributionUrl=https\\://services.gradle.org/distributions/gradle-7.4-all.zip\n');
|
'distributionUrl=https\\://services.gradle.org/distributions/gradle-7.5-all.zip\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
testWithoutContext('injects the wrapper when some files are missing', () {
|
testWithoutContext('injects the wrapper when some files are missing', () {
|
||||||
@ -110,7 +110,7 @@ void main() {
|
|||||||
'distributionPath=wrapper/dists\n'
|
'distributionPath=wrapper/dists\n'
|
||||||
'zipStoreBase=GRADLE_USER_HOME\n'
|
'zipStoreBase=GRADLE_USER_HOME\n'
|
||||||
'zipStorePath=wrapper/dists\n'
|
'zipStorePath=wrapper/dists\n'
|
||||||
'distributionUrl=https\\://services.gradle.org/distributions/gradle-7.4-all.zip\n');
|
'distributionUrl=https\\://services.gradle.org/distributions/gradle-7.5-all.zip\n');
|
||||||
});
|
});
|
||||||
|
|
||||||
testWithoutContext('injects the wrapper and the Gradle version is derivated from the AGP version', () {
|
testWithoutContext('injects the wrapper and the Gradle version is derivated from the AGP version', () {
|
||||||
|
@ -58,12 +58,12 @@ void main() {
|
|||||||
final RegExp androidPluginRegExp =
|
final RegExp androidPluginRegExp =
|
||||||
RegExp(r'com\.android\.tools\.build:gradle:(\d+\.\d+\.\d+)');
|
RegExp(r'com\.android\.tools\.build:gradle:(\d+\.\d+\.\d+)');
|
||||||
|
|
||||||
// Use AGP 4.1.0
|
// Use AGP 7.2.0
|
||||||
final String newBuildGradle = buildGradle.replaceAll(
|
final String newBuildGradle = buildGradle.replaceAll(
|
||||||
androidPluginRegExp, 'com.android.tools.build:gradle:4.1.0');
|
androidPluginRegExp, 'com.android.tools.build:gradle:7.2.0');
|
||||||
buildGradleFile.writeAsStringSync(newBuildGradle);
|
buildGradleFile.writeAsStringSync(newBuildGradle);
|
||||||
|
|
||||||
// Run flutter build apk using AGP 4.1.0
|
// Run flutter build apk using AGP 7.2.0
|
||||||
result = processManager.runSync(<String>[
|
result = processManager.runSync(<String>[
|
||||||
flutterBin,
|
flutterBin,
|
||||||
...getLocalEngineArguments(),
|
...getLocalEngineArguments(),
|
||||||
|
Loading…
Reference in New Issue
Block a user