Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
5c691893
Unverified
Commit
5c691893
authored
Mar 31, 2022
by
Emmanuel Garcia
Committed by
GitHub
Mar 31, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate AGP and Gradle versions to 7.1.2/7.4 (#99723)
parent
6baca0db
Changes
14
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
214 additions
and
125 deletions
+214
-125
.ci.yaml
.ci.yaml
+126
-94
build_aar_module_test.dart
dev/devicelab/bin/tasks/build_aar_module_test.dart
+1
-1
gradle_plugin_light_apk_test.dart
dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart
+0
-1
apk_utils.dart
dev/devicelab/lib/framework/apk_utils.dart
+2
-21
gradle_errors.dart
packages/flutter_tools/lib/src/android/gradle_errors.dart
+23
-0
gradle_utils.dart
packages/flutter_tools/lib/src/android/gradle_utils.dart
+7
-2
project.dart
packages/flutter_tools/lib/src/project.dart
+1
-0
build.gradle.tmpl
...r_tools/templates/module/android/gradle/build.gradle.tmpl
+1
-1
build.gradle.tmpl
...ools/templates/plugin/android-java.tmpl/build.gradle.tmpl
+1
-1
build.gradle.tmpl
...tools/templates/plugin_ffi/android.tmpl/build.gradle.tmpl
+1
-1
gradle_errors_test.dart
..._tools/test/general.shard/android/gradle_errors_test.dart
+44
-0
gradle_find_bundle_test.dart
...s/test/general.shard/android/gradle_find_bundle_test.dart
+1
-1
gradle_test.dart
...flutter_tools/test/general.shard/android/gradle_test.dart
+4
-0
gradle_utils_test.dart
...r_tools/test/general.shard/android/gradle_utils_test.dart
+2
-2
No files found.
.ci.yaml
View file @
5c691893
This diff is collapsed.
Click to expand it.
dev/devicelab/bin/tasks/build_aar_module_test.dart
View file @
5c691893
...
...
@@ -262,7 +262,7 @@ Future<void> main() async {
}
catch
(
e
)
{
return
TaskResult
.
failure
(
e
.
toString
());
}
finally
{
//
rmTree(tempDir);
rmTree
(
tempDir
);
}
});
}
dev/devicelab/bin/tasks/gradle_plugin_light_apk_test.dart
View file @
5c691893
...
...
@@ -235,7 +235,6 @@ Future<void> main() async {
await
runProjectTest
((
FlutterProject
project
)
async
{
section
(
'gradlew assembleLocal (plugin with custom build type)'
);
await
project
.
addCustomBuildType
(
'local'
,
initWith:
'debug'
);
await
project
.
addGlobalBuildType
(
'local'
,
initWith:
'debug'
);
section
(
'Add plugin'
);
project
.
addPlugin
(
'path_provider'
);
await
project
.
getPackages
();
...
...
dev/devicelab/lib/framework/apk_utils.dart
View file @
5c691893
...
...
@@ -37,7 +37,8 @@ Future<void> runProjectTest(Future<void> Function(FlutterProject project) testFu
try
{
await
testFunction
(
project
);
}
finally
{
rmTree
(
tempDir
);
print
(
'tempDir=
$tempDir
'
);
// rmTree(tempDir);
}
}
...
...
@@ -274,26 +275,6 @@ android {
'''
);
}
Future
<
void
>
addGlobalBuildType
(
String
name
,
{
required
String
initWith
})
async
{
final
File
buildScript
=
File
(
path
.
join
(
androidPath
,
'build.gradle'
),
);
buildScript
.
openWrite
(
mode:
FileMode
.
append
).
write
(
'''
subprojects {
afterEvaluate {
android {
buildTypes {
$name
{
initWith
$initWith
}
}
}
}
}
'''
);
}
/// Adds a plugin to the pubspec.
/// In pubspec, each dependency is expressed as key, value pair joined by a colon `:`.
/// such as `plugin_a`:`^0.0.1` or `plugin_a`:`\npath: /some/path`.
...
...
packages/flutter_tools/lib/src/android/gradle_errors.dart
View file @
5c691893
...
...
@@ -77,6 +77,7 @@ final List<GradleHandledError> gradleErrors = <GradleHandledError>[
multidexErrorHandler
,
incompatibleKotlinVersionHandler
,
minCompileSdkVersionHandler
,
jvm11Required
,
];
const
String
_boxTitle
=
'Flutter Fix'
;
...
...
@@ -538,3 +539,25 @@ final GradleHandledError minCompileSdkVersionHandler = GradleHandledError(
},
eventLabel:
'min-compile-sdk-version'
,
);
@visibleForTesting
final
GradleHandledError
jvm11Required
=
GradleHandledError
(
test:
(
String
line
)
{
return
line
.
contains
(
'Android Gradle plugin requires Java 11 to run'
);
},
handler:
({
required
String
line
,
required
FlutterProject
project
,
required
bool
usesAndroidX
,
required
bool
multidexEnabled
,
})
async
{
globals
.
printBox
(
'
${globals.logger.terminal.warningMark}
You need Java 11 or higher to build your app with this version of Gradle.
\n\n
'
'To get Java 11, update to the latest version of Android Studio on https://developer.android.com/studio/install.
\n\n
'
'To check the Java version used by Flutter, run `flutter doctor -v`.'
,
title:
_boxTitle
,
);
return
GradleBuildStatus
.
exit
;
},
eventLabel:
'java11-required'
,
);
packages/flutter_tools/lib/src/android/gradle_utils.dart
View file @
5c691893
...
...
@@ -27,8 +27,10 @@ import 'android_sdk.dart';
// For more information about the latest version, check:
// https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
// https://kotlinlang.org/docs/gradle.html#plugin-and-versions
const
String
templateDefaultGradleVersion
=
'6.7'
;
const
String
templateAndroidGradlePluginVersion
=
'4.1.0'
;
const
String
templateDefaultGradleVersion
=
'7.4'
;
const
String
templateAndroidGradlePluginVersion
=
'7.1.2'
;
// TODO(egarciad): Gradle 7 breaks AARs builds: https://github.com/flutter/flutter/issues/101083
const
String
templateAndroidGradlePluginVersionForModule
=
'4.1.0'
;
const
String
templateKotlinGradlePluginVersion
=
'1.6.10'
;
final
RegExp
_androidPluginRegExp
=
RegExp
(
r'com\.android\.tools\.build:gradle:(\d+\.\d+\.\d+)'
);
...
...
@@ -192,6 +194,9 @@ String getGradleVersionFor(String androidPluginVersion) {
if
(
_isWithinVersionRange
(
androidPluginVersion
,
min:
'4.0.0'
,
max:
'4.1.0'
))
{
return
'6.7'
;
}
if
(
_isWithinVersionRange
(
androidPluginVersion
,
min:
'7.0'
,
max:
'7.4'
))
{
return
'7.4'
;
}
throwToolExit
(
'Unsupported Android Plugin version:
$androidPluginVersion
.'
);
}
...
...
packages/flutter_tools/lib/src/project.dart
View file @
5c691893
...
...
@@ -587,6 +587,7 @@ class AndroidProject extends FlutterProjectPlatform {
'androidIdentifier'
:
androidIdentifier
,
'androidX'
:
usesAndroidX
,
'agpVersion'
:
gradle
.
templateAndroidGradlePluginVersion
,
'agpVersionForModule'
:
gradle
.
templateAndroidGradlePluginVersionForModule
,
'kotlinVersion'
:
gradle
.
templateKotlinGradlePluginVersion
,
'gradleVersion'
:
gradle
.
templateDefaultGradleVersion
,
},
...
...
packages/flutter_tools/templates/module/android/gradle/build.gradle.tmpl
View file @
5c691893
...
...
@@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:{{agpVersion}}'
classpath 'com.android.tools.build:gradle:{{agpVersion
ForModule
}}'
}
}
...
...
packages/flutter_tools/templates/plugin/android-java.tmpl/build.gradle.tmpl
View file @
5c691893
...
...
@@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:
4.1.0
'
classpath 'com.android.tools.build:gradle:
{{agpVersion}}
'
}
}
...
...
packages/flutter_tools/templates/plugin_ffi/android.tmpl/build.gradle.tmpl
View file @
5c691893
...
...
@@ -11,7 +11,7 @@ buildscript {
dependencies {
// The Android Gradle Plugin knows how to build native code with the NDK.
classpath 'com.android.tools.build:gradle:
4.1.0
'
classpath 'com.android.tools.build:gradle:
{{agpVersion}}
'
}
}
...
...
packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart
View file @
5c691893
...
...
@@ -35,6 +35,7 @@ void main() {
multidexErrorHandler
,
incompatibleKotlinVersionHandler
,
minCompileSdkVersionHandler
,
jvm11Required
,
])
);
});
...
...
@@ -955,6 +956,49 @@ Execution failed for task ':app:checkDebugAarMetadata'.
ProcessManager:
()
=>
FakeProcessManager
.
empty
(),
});
});
group
(
'Java 11 requirement'
,
()
{
testWithoutContext
(
'pattern'
,
()
{
expect
(
jvm11Required
.
test
(
'''
* What went wrong:
A problem occurred evaluating project '
:
flutter
'.
> Failed to apply plugin '
com
.
android
.
internal
.
library
'.
> Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8.
You can try some of the following options:
- changing the IDE settings.
- changing the JAVA_HOME environment variable.
- changing `org.gradle.java.home` in `gradle.properties`.'''
),
isTrue
,
);
});
testUsingContext
(
'suggestion'
,
()
async
{
await
jvm11Required
.
handler
();
expect
(
testLogger
.
statusText
,
contains
(
'
\n
'
'┌─ Flutter Fix ─────────────────────────────────────────────────────────────────┐
\n
'
'│ [!] You need Java 11 or higher to build your app with this version of Gradle. │
\n
'
'│ │
\n
'
'│ To get Java 11, update to the latest version of Android Studio on │
\n
'
'│ https://developer.android.com/studio/install. │
\n
'
'│ │
\n
'
'│ To check the Java version used by Flutter, run `flutter doctor -v`. │
\n
'
'└───────────────────────────────────────────────────────────────────────────────┘
\n
'
)
);
},
overrides:
<
Type
,
Generator
>{
GradleUtils:
()
=>
FakeGradleUtils
(),
Platform:
()
=>
fakePlatform
(
'android'
),
FileSystem:
()
=>
MemoryFileSystem
.
test
(),
ProcessManager:
()
=>
FakeProcessManager
.
empty
(),
});
});
}
bool
formatTestErrorMessage
(
String
errorMessage
,
GradleHandledError
error
)
{
...
...
packages/flutter_tools/test/general.shard/android/gradle_find_bundle_test.dart
View file @
5c691893
...
...
@@ -357,7 +357,7 @@ void main() {
'gradle'
,
label:
'gradle-expected-file-not-found'
,
parameters:
CustomDimensions
.
fromMap
(<
String
,
String
>
{
'cd37'
:
'androidGradlePluginVersion:
6.7
, fileExtension: .aab'
,
'cd37'
:
'androidGradlePluginVersion:
7.4
, fileExtension: .aab'
,
}),
),
));
...
...
packages/flutter_tools/test/general.shard/android/gradle_test.dart
View file @
5c691893
...
...
@@ -445,6 +445,10 @@ flutter:
expect
(
getGradleVersionFor
(
'4.0.0'
),
'6.7'
);
expect
(
getGradleVersionFor
(
'4.1.0'
),
'6.7'
);
expect
(
getGradleVersionFor
(
'7.0'
),
'7.4'
);
expect
(
getGradleVersionFor
(
'7.1.2'
),
'7.4'
);
expect
(
getGradleVersionFor
(
'7.2'
),
'7.4'
);
});
testWithoutContext
(
'throws on unsupported versions'
,
()
{
...
...
packages/flutter_tools/test/general.shard/android/gradle_utils_test.dart
View file @
5c691893
...
...
@@ -73,7 +73,7 @@ void main() {
'distributionPath=wrapper/dists
\n
'
'zipStoreBase=GRADLE_USER_HOME
\n
'
'zipStorePath=wrapper/dists
\n
'
'distributionUrl=https
\\
://services.gradle.org/distributions/gradle-
6.7
-all.zip
\n
'
);
'distributionUrl=https
\\
://services.gradle.org/distributions/gradle-
7.4
-all.zip
\n
'
);
});
testWithoutContext
(
'injects the wrapper when some files are missing'
,
()
{
...
...
@@ -110,7 +110,7 @@ void main() {
'distributionPath=wrapper/dists
\n
'
'zipStoreBase=GRADLE_USER_HOME
\n
'
'zipStorePath=wrapper/dists
\n
'
'distributionUrl=https
\\
://services.gradle.org/distributions/gradle-
6.7
-all.zip
\n
'
);
'distributionUrl=https
\\
://services.gradle.org/distributions/gradle-
7.4
-all.zip
\n
'
);
});
testWithoutContext
(
'injects the wrapper and the Gradle version is derivated from the AGP version'
,
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment