Skip to content

Commit

Permalink
Upgrade template Gradle, App AGP, Module AGP, and Kotlin versions, an…
Browse files Browse the repository at this point in the history
…d tests (flutter#150969)

After the land of flutter/engine#53592, there is some log spam:
```
e: /Users/mackall/.gradle/caches/transforms-3/c1e137371ec1afe9bc9bd7b05823752d/transformed/fragment-1.7.1/jars/classes.jar!/META-INF/fragment_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
e: /Users/mackall/.gradle/caches/transforms-3/d86c7cb1c556fe1655fa56db671c649c/transformed/jetified-activity-1.8.1/jars/classes.jar!/META-INF/activity_release.kotlin_module: Module was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.8.0, expected version is 1.6.0.
...
```

I think this is harmless, but still annoying. Upgrading the AGP version fixes it. To be honest, I don't know why (I expected the Kotlin version would do it). But after flutter#146307, our tests have been running on AGP/Gradle 8.1/8.3 for a while, so it makes sense to upgrade anyways.

In a follow up PR:
1. Also upgrade the tests that were left behind in flutter#146307, as I think removal of discontinued plugins paved the way here.
  • Loading branch information
gmackall authored and victorsanni committed Jul 8, 2024
1 parent 6d92f1b commit a0096da
Show file tree
Hide file tree
Showing 11 changed files with 170 additions and 36 deletions.
28 changes: 27 additions & 1 deletion .ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ targets:
{"dependency": "cmake", "version": "build_id:8787856497187628321"},
{"dependency": "goldctl", "version": "git_revision:720a542f6fe4f92922c3b8f0fdcc4d2ac6bb83cd"},
{"dependency": "ninja", "version": "version:1.9.0"},
{"dependency": "open_jdk", "version": "version:11"}
{"dependency": "open_jdk", "version": "version:17"}
]
shard: android_preview_tool_integration_tests
tags: >
Expand All @@ -1167,6 +1167,32 @@ targets:
- bin/**
- .ci.yaml

- name: Linux android_java11_tool_integration_tests
recipe: flutter/flutter_drone
bringup: true
timeout: 60
properties:
add_recipes_cq: "true"
dependencies: >-
[
{"dependency": "android_sdk", "version": "version:34v3"},
{"dependency": "chrome_and_driver", "version": "version:125.0.6422.141"},
{"dependency": "clang", "version": "git_revision:5d5aba78dbbee75508f01bcaa69aedb2ab79065a"},
{"dependency": "cmake", "version": "build_id:8787856497187628321"},
{"dependency": "goldctl", "version": "git_revision:720a542f6fe4f92922c3b8f0fdcc4d2ac6bb83cd"},
{"dependency": "ninja", "version": "version:1.9.0"},
{"dependency": "open_jdk", "version": "version:11"}
]
shard: android_java11_tool_integration_tests
tags: >
["framework", "hostonly", "shard", "linux"]
test_timeout_secs: "2700"
runIf:
- dev/**
- packages/flutter_tools/**
- bin/**
- .ci.yaml

- name: Linux tool_tests_commands
recipe: flutter/flutter_drone
timeout: 60
Expand Down
2 changes: 2 additions & 0 deletions TESTOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@
# test_ownership @keyonghan
# tool_host_cross_arch_tests @andrewkolos @flutter/tool
# tool_integration_tests @christopherfujino @flutter/tool
# android_preview_tool_integration_tests @gmackall @flutter/android
# android_java11_tool_integration_tests @gmackall @flutter/android
# tool_tests @andrewkolos @flutter/tool
# verify_binaries_codesigned @cbracken @flutter/releases
# web_canvaskit_tests @yjbanov @flutter/web
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:io';

import 'package:path/path.dart' as path;

import '../utils.dart';

Future<void> androidJava11IntegrationToolTestsRunner() async {
final String toolsPath = path.join(flutterRoot, 'packages', 'flutter_tools');

final List<String> allTests = Directory(path.join(toolsPath, 'test', 'android_java11_integration.shard'))
.listSync(recursive: true).whereType<File>()
.map<String>((FileSystemEntity entry) => path.relative(entry.path, from: toolsPath))
.where((String testPath) => path.basename(testPath).endsWith('_test.dart')).toList();

await runDartTest(
toolsPath,
forceSingleCore: true,
testPaths: selectIndexOfTotalSubshard<String>(allTests),
collectMetrics: true,
);
}
2 changes: 2 additions & 0 deletions dev/bots/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import 'package:path/path.dart' as path;
import 'run_command.dart';
import 'suite_runners/run_add_to_app_life_cycle_tests.dart';
import 'suite_runners/run_analyze_tests.dart';
import 'suite_runners/run_android_java11_integration_tool_tests.dart';
import 'suite_runners/run_android_preview_integration_tool_tests.dart';
import 'suite_runners/run_customer_testing_tests.dart';
import 'suite_runners/run_docs_tests.dart';
Expand Down Expand Up @@ -131,6 +132,7 @@ Future<void> main(List<String> args) async {
'web_tool_tests': _runWebToolTests,
'tool_integration_tests': _runIntegrationToolTests,
'android_preview_tool_integration_tests': androidPreviewIntegrationToolTestsRunner,
'android_java11_tool_integration_tests': androidJava11IntegrationToolTestsRunner,
'tool_host_cross_arch_tests': _runToolHostCrossArchTests,
// All the unit/widget tests run using `flutter test --platform=chrome --web-renderer=html`
'web_tests': webTestsSuite.runWebHtmlUnitTests,
Expand Down
58 changes: 49 additions & 9 deletions packages/flutter_tools/lib/src/android/gradle_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ import 'android_sdk.dart';
// However, this currently requires to migrate existing integration tests to the latest supported values.
//
// Please see the README before changing any of these values.
const String templateDefaultGradleVersion = '7.6.3';
const String templateAndroidGradlePluginVersion = '7.3.0';
const String templateAndroidGradlePluginVersionForModule = '7.3.0';
const String templateKotlinGradlePluginVersion = '1.7.10';
const String templateDefaultGradleVersion = '8.3';
const String templateAndroidGradlePluginVersion = '8.1.0';
const String templateAndroidGradlePluginVersionForModule = '8.1.0';
const String templateKotlinGradlePluginVersion = '1.8.22';

// The Flutter Gradle Plugin is only applied to app projects, and modules that
// are built from source using (`include_flutter.groovy`). The remaining
Expand All @@ -48,24 +48,24 @@ const String ndkVersion = '23.1.7779620';
// Update these when new major versions of Java are supported by new Gradle
// versions that we support.
// Source of truth: https://docs.gradle.org/current/userguide/compatibility.html
const String oneMajorVersionHigherJavaVersion = '20';
const String oneMajorVersionHigherJavaVersion = '23';

// Update this when new versions of Gradle come out including minor versions
// and should correspond to the maximum Gradle version we test in CI.
//
// Supported here means supported by the tooling for
// flutter analyze --suggestions and does not imply broader flutter support.
const String maxKnownAndSupportedGradleVersion = '8.0.2';
const String maxKnownAndSupportedGradleVersion = '8.7';

// Update this when new versions of AGP come out.
//
// Supported here means tooling is aware of this version's Java <-> AGP
// compatibility.
@visibleForTesting
const String maxKnownAndSupportedAgpVersion = '8.1';
const String maxKnownAndSupportedAgpVersion = '8.4.0';

// Update this when new versions of AGP come out.
const String maxKnownAgpVersion = '8.3';
const String maxKnownAgpVersion = '8.5';

// Oldest documented version of AGP that has a listed minimum
// compatible Java version.
Expand Down Expand Up @@ -440,6 +440,22 @@ bool validateGradleAndAgp(Logger logger,
}

// Begin Known Gradle <-> AGP validation.
if (isWithinVersionRange(agpV, min: '8.4.0', max: '8.4.99')) {
return isWithinVersionRange(gradleV,
min: '8.6', max: maxKnownAndSupportedGradleVersion);
}
if (isWithinVersionRange(agpV, min: '8.3.0', max: '8.3.99')) {
return isWithinVersionRange(gradleV,
min: '8.4', max: maxKnownAndSupportedGradleVersion);
}
if (isWithinVersionRange(agpV, min: '8.2.0', max: '8.2.99')) {
return isWithinVersionRange(gradleV,
min: '8.2', max: maxKnownAndSupportedGradleVersion);
}
if (isWithinVersionRange(agpV, min: '8.0.0', max: '8.1.99')) {
return isWithinVersionRange(gradleV,
min: '8.0', max: maxKnownAndSupportedGradleVersion);
}
// Max agp here is a made up version to contain all 7.4 changes.
if (isWithinVersionRange(agpV, min: '7.4', max: '7.5')) {
return isWithinVersionRange(gradleV,
Expand Down Expand Up @@ -693,7 +709,13 @@ String getGradleVersionFor(String androidPluginVersion) {
GradleForAgp(agpMin: '4.0.0', agpMax: '4.1.0', minRequiredGradle: '6.7'),
// 7.5 is a made up value to include everything through 7.4.*
GradleForAgp(agpMin: '7.0.0', agpMax: '7.5', minRequiredGradle: '7.5'),
GradleForAgp(agpMin: '7.5.0', agpMax: '100.100', minRequiredGradle: '8.0'),
// Use 0 and 99 as a patch values to signify every AGP patch version with
// that major and minor version.
GradleForAgp(agpMin: '8.0.0', agpMax: '8.1.99', minRequiredGradle: '8.0'),
GradleForAgp(agpMin: '8.2.0', agpMax: '8.2.99', minRequiredGradle: '8.2'),
GradleForAgp(agpMin: '8.3.0', agpMax: '8.3.99', minRequiredGradle: '8.4'),
GradleForAgp(agpMin: '8.4.0', agpMax: '8.4.99', minRequiredGradle: '8.6'),
GradleForAgp(agpMin: '8.5.0', agpMax: '100.100', minRequiredGradle: '8.7'),
// Assume if AGP is newer than this code know about return the highest gradle
// version we know about.
GradleForAgp(agpMin: maxKnownAgpVersion, agpMax: maxKnownAgpVersion, minRequiredGradle: maxKnownAndSupportedGradleVersion),
Expand Down Expand Up @@ -888,6 +910,24 @@ String getGradlewFileName(Platform platform) {
/// of Gradle, as https://docs.gradle.org/current/userguide/compatibility.html
/// details.
List<JavaGradleCompat> _javaGradleCompatList = const <JavaGradleCompat>[
JavaGradleCompat(
javaMin: '22',
javaMax: '23',
gradleMin: '8.7',
gradleMax: maxKnownAndSupportedGradleVersion,
),
JavaGradleCompat(
javaMin: '21',
javaMax: '22',
gradleMin: '8.4',
gradleMax: maxKnownAndSupportedGradleVersion,
),
JavaGradleCompat(
javaMin: '20',
javaMax: '21',
gradleMin: '8.1',
gradleMax: maxKnownAndSupportedGradleVersion,
),
JavaGradleCompat(
javaMin: '19',
javaMax: '20',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3735,7 +3735,7 @@ void main() {
logger.clear();
}
}, overrides: <Type, Generator>{
Java: () => FakeJava(version: const software.Version.withText(14, 0, 0, '14.0.0')), // Middle compatible Java version with current template AGP/Gradle versions.
Java: () => FakeJava(version: const software.Version.withText(20, 0, 0, '20.0.0')), // Middle compatible Java version with current template AGP/Gradle versions.
Logger: () => logger,
});

Expand All @@ -3762,7 +3762,7 @@ void main() {
logger.clear();
}
}, overrides: <Type, Generator>{
Java: () => FakeJava(version: const software.Version.withText(17, 0, 0, '18.0.0')), // Maximum compatible Java version with current template AGP/Gradle versions.
Java: () => FakeJava(version: const software.Version.withText(17, 0, 0, '22.0.0')), // Maximum compatible Java version with current template AGP/Gradle versions.
Logger: () => logger,
});

Expand All @@ -3789,7 +3789,7 @@ void main() {
logger.clear();
}
}, overrides: <Type, Generator>{
Java: () => FakeJava(version: const software.Version.withText(11, 0, 0, '11.0.0')), // Minimum compatible Java version with current template AGP/Gradle versions.
Java: () => FakeJava(version: const software.Version.withText(17, 0, 0, '17.0.0')), // Minimum compatible Java version with current template AGP/Gradle versions.
Logger: () => logger,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -913,10 +913,10 @@ A problem occurred evaluating project ':app'.
'│ To fix this issue, replace the following content: │\n'
'│ /android/build.gradle: │\n'
"│ - classpath 'com.android.tools.build:gradle:<current-version>' │\n"
"│ + classpath 'com.android.tools.build:gradle:7.3.0' │\n"
"│ + classpath 'com.android.tools.build:gradle:$templateAndroidGradlePluginVersion' │\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-7.6.3-all.zip │\n'
'│ + https://services.gradle.org/distributions/gradle-$templateDefaultGradleVersion-all.zip \n'
'└──────────────────────────────────────────────────────────────────────────────────┘\n'
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/gradle.dart';
import 'package:flutter_tools/src/android/gradle_utils.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/logger.dart';
import 'package:flutter_tools/src/build_info.dart';
Expand Down Expand Up @@ -431,7 +432,7 @@ void main() {
'gradle',
label: 'gradle-expected-file-not-found',
parameters: CustomDimensions.fromMap(<String, String> {
'cd37': 'androidGradlePluginVersion: 7.6.3, fileExtension: .aab',
'cd37': 'androidGradlePluginVersion: $templateDefaultGradleVersion, fileExtension: .aab',
}),
),
));
Expand All @@ -442,7 +443,7 @@ void main() {
Event.flutterBuildInfo(
label: 'gradle-expected-file-not-found',
buildType: 'gradle',
settings: 'androidGradlePluginVersion: 7.6.3, fileExtension: .aab',
settings: 'androidGradlePluginVersion: $templateDefaultGradleVersion, fileExtension: .aab',
),
),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,9 @@ flutter:
});
});

group('gradgradle_utils.le version', () {
group('gradle version', () {
testWithoutContext('should be compatible with the Android plugin version', () {
// Grangradle_utils.ular versions.
// Granular versions.
expect(gradle_utils.getGradleVersionFor('1.0.0'), '2.3');
expect(gradle_utils.getGradleVersionFor('1.0.1'), '2.3');
expect(gradle_utils.getGradleVersionFor('1.0.2'), '2.3');
Expand All @@ -427,7 +427,7 @@ flutter:
expect(gradle_utils.getGradleVersionFor('1.1.2'), '2.3');
expect(gradle_utils.getGradleVersionFor('1.1.2'), '2.3');
expect(gradle_utils.getGradleVersionFor('1.1.3'), '2.3');
// Versgradle_utils.ion Ranges.
// Version Ranges.
expect(gradle_utils.getGradleVersionFor('1.2.0'), '2.9');
expect(gradle_utils.getGradleVersionFor('1.3.1'), '2.9');

Expand Down Expand Up @@ -461,7 +461,11 @@ flutter:
expect(gradle_utils.getGradleVersionFor('7.1.2'), '7.5');
expect(gradle_utils.getGradleVersionFor('7.2'), '7.5');
expect(gradle_utils.getGradleVersionFor('8.0'), '8.0');
expect(gradle_utils.getGradleVersionFor(gradle_utils.maxKnownAgpVersion), '8.0');
expect(gradle_utils.getGradleVersionFor('8.1'), '8.0');
expect(gradle_utils.getGradleVersionFor('8.2'), '8.2');
expect(gradle_utils.getGradleVersionFor('8.3'), '8.4');
expect(gradle_utils.getGradleVersionFor('8.4'), '8.6');
expect(gradle_utils.getGradleVersionFor(gradle_utils.maxKnownAgpVersion), '8.7');
});

testWithoutContext('throws on unsupported versions', () {
Expand Down
Loading

0 comments on commit a0096da

Please sign in to comment.