Unverified Commit 675fec80 authored by Camille Simon's avatar Camille Simon Committed by GitHub

[Android] Support Android 34 (#137191)

Adds support for Android 34 in the following ways:

- Bumps integration tests compile SDK versions 33 --> 34
- Bumps template compile SDK version 33 --> 34
- Also changes deprecated `compileSdkVersion` to `compileSdk`

Part of https://github.com/flutter/flutter/issues/134220
parent 15451e49
......@@ -28,7 +28,7 @@ if (flutterVersionName == null) {
android {
namespace "com.example.a11y_assessments"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
......
......@@ -20,7 +20,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.yourcompany.complexLayout"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_11
......
......@@ -30,7 +30,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.example.macrobenchmarks"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -20,7 +20,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.yourcompany.microbenchmarks"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -14,7 +14,7 @@ android {
}
namespace "dev.flutter.multipleflutters"
compileSdkVersion 33
compileSdk 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -20,7 +20,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "dev.benchmarks.platform_views_layout"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -20,7 +20,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "dev.benchmarks.platform_views_layout_hybrid_composition"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -30,7 +30,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "io.flutter.examples.stocks"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -30,7 +30,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -5,7 +5,7 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 33
compileSdk 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -30,7 +30,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -5,7 +5,7 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 33
compileSdk 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -19,7 +19,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -29,7 +29,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -31,7 +31,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.example.channels"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
......
......@@ -37,7 +37,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "io.flutter.integration.deferred_components_test"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
......
......@@ -24,7 +24,7 @@ apply plugin: "com.android.dynamic-feature"
android {
namespace "io.flutter.integration.deferred_components_test.component1"
compileSdkVersion 33
compileSdk 34
sourceSets {
applicationVariants.all { variant ->
......
......@@ -19,7 +19,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -20,7 +20,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.yourcompany.flavors"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -41,7 +41,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "io.flutter.demo.gallery"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -19,7 +19,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 33
compileSdk 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -29,7 +29,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -5,7 +5,7 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 33
compileSdk 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -30,7 +30,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -19,7 +19,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -29,7 +29,7 @@ apply plugin: 'com.android.application'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -31,7 +31,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.example.spell_check"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
......
......@@ -20,7 +20,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.yourcompany.integration_ui"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -30,7 +30,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -30,7 +30,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -31,7 +31,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "dev.flutter.flutter_api_samples"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -30,7 +30,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.example.view"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -27,7 +27,7 @@ if (flutterVersionName == null) {
android {
namespace "io.flutter.examples.hello_world"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -30,7 +30,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.example.image_list"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -30,7 +30,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "io.flutter.examples.Layers"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -30,7 +30,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "com.example.platformchannel"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -30,7 +30,7 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
namespace "io.flutter.examples.platform_view"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -41,7 +41,7 @@ import org.gradle.internal.os.OperatingSystem
*/
class FlutterExtension {
/** Sets the compileSdkVersion used by default in Flutter app projects. */
static int compileSdkVersion = 33
static int compileSdkVersion = 34
/** Sets the minSdkVersion used by default in Flutter app projects. */
static int minSdkVersion = 19
......
......@@ -613,10 +613,10 @@ final GradleHandledError minCompileSdkVersionHandler = GradleHandledError(
.childDirectory('app')
.childFile('build.gradle');
globals.printBox(
'${globals.logger.terminal.warningMark} Your project requires a higher compileSdkVersion.\n'
'Fix this issue by bumping the compileSdkVersion in ${gradleFile.path}:\n'
'${globals.logger.terminal.warningMark} Your project requires a higher compileSdk version.\n'
'Fix this issue by bumping the compileSdk version in ${gradleFile.path}:\n'
'android {\n'
' compileSdkVersion ${minCompileSdkVersionMatch?.group(1)}\n'
' compileSdk ${minCompileSdkVersionMatch?.group(1)}\n'
'}',
title: _boxTitle,
);
......
......@@ -39,7 +39,7 @@ const String templateKotlinGradlePluginVersion = '1.7.10';
// so new versions are picked up after a Flutter upgrade.
//
// Please see the README before changing any of these values.
const String compileSdkVersion = '33';
const String compileSdkVersion = '34';
const String minSdkVersion = '19';
const String targetSdkVersion = '33';
const String ndkVersion = '23.1.7779620';
......
......@@ -24,7 +24,7 @@ if (flutterVersionName == null) {
android {
namespace "{{androidIdentifier}}"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
......
......@@ -24,7 +24,7 @@ if (flutterVersionName == null) {
android {
namespace "{{androidIdentifier}}"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
......
......@@ -19,7 +19,7 @@ if (flutterVersionName == null) {
apply plugin: "com.android.dynamic-feature"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -29,7 +29,7 @@ android {
namespace '{{androidIdentifier}}'
}
compileSdkVersion {{compileSdkVersion}}
compileSdk {{compileSdkVersion}}
defaultConfig {
minSdkVersion {{minSdkVersion}}
}
......
......@@ -8,7 +8,7 @@ android {
namespace "{{androidIdentifier}}.host"
}
compileSdkVersion {{compileSdkVersion}}
compileSdk {{compileSdkVersion}}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -35,7 +35,7 @@ android {
namespace '{{androidIdentifier}}'
}
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
......
......@@ -26,7 +26,7 @@ android {
namespace '{{androidIdentifier}}'
}
compileSdkVersion {{compileSdkVersion}}
compileSdk {{compileSdkVersion}}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -29,7 +29,7 @@ android {
namespace '{{androidIdentifier}}'
}
compileSdkVersion {{compileSdkVersion}}
compileSdk {{compileSdkVersion}}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -29,9 +29,9 @@ android {
namespace '{{androidIdentifier}}'
}
// Bumping the plugin compileSdkVersion requires all clients of this plugin
// Bumping the plugin compileSdk version requires all clients of this plugin
// to bump the version in their app.
compileSdkVersion {{compileSdkVersion}}
compileSdk {{compileSdkVersion}}
// Use the NDK version
// declared in /android/app/build.gradle file of the Flutter project.
......
......@@ -2865,7 +2865,7 @@ void main() {
final String buildContent = await globals.fs.file('${projectDir.path}/android/app/build.gradle').readAsString();
expect(buildContent.contains('compileSdkVersion flutter.compileSdkVersion'), true);
expect(buildContent.contains('compileSdk flutter.compileSdkVersion'), true);
expect(buildContent.contains('ndkVersion flutter.ndkVersion'), true);
expect(buildContent.contains('targetSdkVersion flutter.targetSdkVersion'), true);
});
......
......@@ -70,7 +70,7 @@ if (flutterVersionName == null) {
android {
namespace "com.example.asset_sample"
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
......
......@@ -1081,13 +1081,13 @@ Execution failed for task ':app:checkDebugAarMetadata'.
testLogger.statusText,
contains(
'\n'
'┌─ Flutter Fix ─────────────────────────────────────────────────────────────────┐\n'
'│ [!] Your project requires a higher compileSdkVersion. │\n'
'│ Fix this issue by bumping the compileSdkVersion in /android/app/build.gradle: │\n'
'│ android { │\n'
'│ compileSdkVersion 31\n'
'│ } │\n'
'└───────────────────────────────────────────────────────────────────────────────┘\n'
'┌─ Flutter Fix ─────────────────────────────────────────────────────────────────\n'
'│ [!] Your project requires a higher compileSdk version. │\n'
'│ Fix this issue by bumping the compileSdk version in /android/app/build.gradle: │\n'
'│ android { \n'
'│ compileSdk 31 \n'
'│ } \n'
'└───────────────────────────────────────────────────────────────────────────────\n'
)
);
}, overrides: <Type, Generator>{
......
......@@ -1662,7 +1662,7 @@ String gradleFileWithApplicationId(String id) {
return '''
apply plugin: 'com.android.application'
android {
compileSdkVersion 33
compileSdk 34
defaultConfig {
applicationId '$id'
......@@ -1679,7 +1679,7 @@ version '1.0-SNAPSHOT'
apply plugin: 'com.android.library'
android {
compileSdkVersion 33
compileSdk 34
}
''';
}
......
......@@ -23,7 +23,7 @@ void main() {
tryToDelete(tempDir);
});
test('error logged when plugin Android compileSdkVersion higher than project', () async {
test('error logged when plugin Android compileSdk version higher than project', () async {
final String flutterBin = fileSystem.path.join(
getFlutterRoot(),
'bin',
......@@ -46,10 +46,10 @@ void main() {
final String pluginBuildGradle = pluginGradleFile.readAsStringSync();
// Bump up plugin compileSdkVersion to 31
final RegExp androidCompileSdkVersionRegExp = RegExp(r'compileSdkVersion ([0-9]+|flutter.compileSdkVersion)');
// Bump up plugin compileSdk version to 31
final RegExp androidCompileSdkVersionRegExp = RegExp(r'compileSdk ([0-9]+|flutter.compileSdkVersion)');
final String newPluginGradleFile = pluginBuildGradle.replaceAll(
androidCompileSdkVersionRegExp, 'compileSdkVersion 31');
androidCompileSdkVersionRegExp, 'compileSdk 31');
pluginGradleFile.writeAsStringSync(newPluginGradleFile);
final Directory pluginExampleAppDir = pluginAppDir.childDirectory('example');
......@@ -59,9 +59,9 @@ void main() {
final String projectBuildGradle = projectGradleFile.readAsStringSync();
// Bump down plugin example app compileSdkVersion to 30
// Bump down plugin example app compileSdk version to 30
final String newProjectGradleFile = projectBuildGradle.replaceAll(
androidCompileSdkVersionRegExp, 'compileSdkVersion 30');
androidCompileSdkVersionRegExp, 'compileSdk 30');
projectGradleFile.writeAsStringSync(newProjectGradleFile);
// Run flutter build apk to build plugin example project
......
......@@ -40,12 +40,12 @@ void main() {
'build succeeds targeting string compileSdkVersion',
() async {
final File buildGradleFile = exampleAppDir.childDirectory('android').childDirectory('app').childFile('build.gradle');
// write a build.gradle with compileSdkVersion as `android-Tiramisu` which is a string preview version
// write a build.gradle with compileSdk version as `android-Tiramisu` which is a string preview version
buildGradleFile.writeAsStringSync(
buildGradleFile.readAsStringSync().replaceFirst('compileSdkVersion flutter.compileSdkVersion', 'compileSdkVersion "android-Tiramisu"'),
buildGradleFile.readAsStringSync().replaceFirst('compileSdk flutter.compileSdkVersion', 'compileSdk "android-Tiramisu"'),
flush: true
);
expect(buildGradleFile.readAsStringSync(), contains('compileSdkVersion "android-Tiramisu"'));
expect(buildGradleFile.readAsStringSync(), contains('compileSdk "android-Tiramisu"'));
final ProcessResult result = await processManager.run(<String>[
flutterBin,
......@@ -70,7 +70,7 @@ void main() {
final File buildGradleFile = exampleAppDir.childDirectory('android').childDirectory('app').childFile('build.gradle');
// write a build.gradle with compileSdkPreview as `Tiramisu` which is a string preview version
buildGradleFile.writeAsStringSync(
buildGradleFile.readAsStringSync().replaceFirst('compileSdkVersion flutter.compileSdkVersion', 'compileSdkPreview "Tiramisu"'),
buildGradleFile.readAsStringSync().replaceFirst('compileSdk flutter.compileSdkVersion', 'compileSdkPreview "Tiramisu"'),
flush: true
);
expect(buildGradleFile.readAsStringSync(), contains('compileSdkPreview "Tiramisu"'));
......
......@@ -77,7 +77,7 @@ class DeferredComponentModule {
apply plugin: "com.android.dynamic-feature"
android {
compileSdkVersion 33
compileSdk 34
sourceSets {
applicationVariants.all { variant ->
......
......@@ -175,7 +175,7 @@ class BasicDeferredComponentsConfig extends DeferredComponentsConfig {
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
sourceSets {
......
......@@ -144,7 +144,7 @@ class MultidexProject extends Project {
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 33
compileSdk 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -31,7 +31,7 @@ android {
namespace 'dev.flutter.integration_test'
}
compileSdkVersion 33
compileSdk 34
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
......@@ -33,7 +33,7 @@ android {
if (project.android.hasProperty("namespace")) {
namespace 'com.example.integration_test_example'
}
compileSdkVersion flutter.compileSdkVersion
compileSdk flutter.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
......
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