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
b528310f
Unverified
Commit
b528310f
authored
Apr 07, 2022
by
Emmanuel Garcia
Committed by
GitHub
Apr 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specify Kotlin version in modules and refactor (#101315)
parent
bb300b46
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
75 additions
and
36 deletions
+75
-36
build_aar_module_test.dart
dev/devicelab/bin/tasks/build_aar_module_test.dart
+2
-1
gradle_errors.dart
packages/flutter_tools/lib/src/android/gradle_errors.dart
+8
-8
gradle_utils.dart
packages/flutter_tools/lib/src/android/gradle_utils.dart
+12
-1
create_base.dart
packages/flutter_tools/lib/src/commands/create_base.dart
+5
-0
project.dart
packages/flutter_tools/lib/src/project.dart
+5
-1
build.gradle.tmpl
...r_tools/templates/module/android/gradle/build.gradle.tmpl
+15
-3
settings.gradle.tmpl
...ools/templates/module/android/gradle/settings.gradle.tmpl
+1
-0
AndroidManifest.xml.tmpl
...s/module/android/gradle/src/main/AndroidManifest.xml.tmpl
+3
-0
build.gradle.tmpl
...module/android/host_app_common/app.tmpl/build.gradle.tmpl
+3
-3
build.gradle.tmpl
...ools/templates/plugin/android-java.tmpl/build.gradle.tmpl
+2
-2
build.gradle.tmpl
...ls/templates/plugin/android-kotlin.tmpl/build.gradle.tmpl
+2
-2
build.gradle.tmpl
...tools/templates/plugin_ffi/android.tmpl/build.gradle.tmpl
+3
-3
template_manifest.json
packages/flutter_tools/templates/template_manifest.json
+2
-0
gradle_errors_test.dart
..._tools/test/general.shard/android/gradle_errors_test.dart
+12
-12
No files found.
dev/devicelab/bin/tasks/build_aar_module_test.dart
View file @
b528310f
...
...
@@ -67,7 +67,8 @@ Future<void> main() async {
' plugin_with_android:
$platformLineSep
'
' path: ../plugin_with_android
$platformLineSep
'
' plugin_without_android:
$platformLineSep
'
' path: ../plugin_without_android
$platformLineSep
'
,
' path: ../plugin_without_android
$platformLineSep
'
' webcrypto: 0.5.2
$platformLineSep
'
,
// Plugin that uses NDK.
);
modulePubspec
.
writeAsStringSync
(
content
,
flush:
true
);
...
...
packages/flutter_tools/lib/src/android/gradle_errors.dart
View file @
b528310f
...
...
@@ -71,13 +71,13 @@ final List<GradleHandledError> gradleErrors = <GradleHandledError>[
permissionDeniedErrorHandler
,
flavorUndefinedHandler
,
r8FailureHandler
,
minSdkVersion
,
transformInputIssue
,
lockFileDepMissing
,
minSdkVersion
Handler
,
transformInputIssue
Handler
,
lockFileDepMissing
Handler
,
multidexErrorHandler
,
incompatibleKotlinVersionHandler
,
minCompileSdkVersionHandler
,
jvm11Required
,
jvm11Required
Handler
,
];
const
String
_boxTitle
=
'Flutter Fix'
;
...
...
@@ -381,7 +381,7 @@ final RegExp _minSdkVersionPattern = RegExp(r'uses-sdk:minSdkVersion ([0-9]+) ca
/// Handler when a plugin requires a higher Android API level.
@visibleForTesting
final
GradleHandledError
minSdkVersion
=
GradleHandledError
(
final
GradleHandledError
minSdkVersion
Handler
=
GradleHandledError
(
test:
(
String
line
)
{
return
_minSdkVersionPattern
.
hasMatch
(
line
);
},
...
...
@@ -423,7 +423,7 @@ final GradleHandledError minSdkVersion = GradleHandledError(
/// Handler when https://issuetracker.google.com/issues/141126614 or
/// https://github.com/flutter/flutter/issues/58247 is triggered.
@visibleForTesting
final
GradleHandledError
transformInputIssue
=
GradleHandledError
(
final
GradleHandledError
transformInputIssue
Handler
=
GradleHandledError
(
test:
(
String
line
)
{
return
line
.
contains
(
'https://issuetracker.google.com/issues/158753935'
);
},
...
...
@@ -457,7 +457,7 @@ final GradleHandledError transformInputIssue = GradleHandledError(
/// Handler when a dependency is missing in the lockfile.
@visibleForTesting
final
GradleHandledError
lockFileDepMissing
=
GradleHandledError
(
final
GradleHandledError
lockFileDepMissing
Handler
=
GradleHandledError
(
test:
(
String
line
)
{
return
line
.
contains
(
'which is not part of the dependency lock state'
);
},
...
...
@@ -541,7 +541,7 @@ final GradleHandledError minCompileSdkVersionHandler = GradleHandledError(
);
@visibleForTesting
final
GradleHandledError
jvm11Required
=
GradleHandledError
(
final
GradleHandledError
jvm11Required
Handler
=
GradleHandledError
(
test:
(
String
line
)
{
return
line
.
contains
(
'Android Gradle plugin requires Java 11 to run'
);
},
...
...
packages/flutter_tools/lib/src/android/gradle_utils.dart
View file @
b528310f
...
...
@@ -30,9 +30,20 @@ import 'android_sdk.dart';
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
template
AndroidGradlePlugin
VersionForModule
=
'4.1.0'
;
const
String
template
DefaultGradle
VersionForModule
=
'4.1.0'
;
const
String
templateKotlinGradlePluginVersion
=
'1.6.10'
;
// 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
// using (include_flutter.groovy).
// The remaining projects are: plugins, and modules compiled as AARs. In modules, the ephemeral directory
// `.android` is always regenerated after flutter pub get, so new versions are picked up after a
// Flutter upgrade.
const
String
compileSdkVersion
=
'31'
;
const
String
minSdkVersion
=
'16'
;
const
String
targetSdkVersion
=
'31'
;
const
String
ndkVersion
=
'21.1.6352462'
;
final
RegExp
_androidPluginRegExp
=
RegExp
(
r'com\.android\.tools\.build:gradle:(\d+\.\d+\.\d+)'
);
/// Provides utilities to run a Gradle task, such as finding the Gradle executable
...
...
packages/flutter_tools/lib/src/commands/create_base.dart
View file @
b528310f
...
...
@@ -425,6 +425,11 @@ abstract class CreateBase extends FlutterCommand {
'agpVersion'
:
agpVersion
,
'kotlinVersion'
:
kotlinVersion
,
'gradleVersion'
:
gradleVersion
,
'gradleVersionForModule'
:
gradle
.
templateDefaultGradleVersionForModule
,
'compileSdkVersion'
:
gradle
.
compileSdkVersion
,
'minSdkVersion'
:
gradle
.
minSdkVersion
,
'ndkVersion'
:
gradle
.
ndkVersion
,
'targetSdkVersion'
:
gradle
.
targetSdkVersion
,
};
}
...
...
packages/flutter_tools/lib/src/project.dart
View file @
b528310f
...
...
@@ -587,9 +587,13 @@ class AndroidProject extends FlutterProjectPlatform {
'androidIdentifier'
:
androidIdentifier
,
'androidX'
:
usesAndroidX
,
'agpVersion'
:
gradle
.
templateAndroidGradlePluginVersion
,
'agpVersionForModule'
:
gradle
.
templateAndroidGradlePluginVersionForModule
,
'kotlinVersion'
:
gradle
.
templateKotlinGradlePluginVersion
,
'gradleVersion'
:
gradle
.
templateDefaultGradleVersion
,
'gradleVersionForModule'
:
gradle
.
templateDefaultGradleVersionForModule
,
'compileSdkVersion'
:
gradle
.
compileSdkVersion
,
'minSdkVersion'
:
gradle
.
minSdkVersion
,
'ndkVersion'
:
gradle
.
ndkVersion
,
'targetSdkVersion'
:
gradle
.
targetSdkVersion
,
},
printStatusWhenWriting:
false
,
);
...
...
packages/flutter_tools/templates/module/android/gradle/build.gradle.tmpl
View file @
b528310f
// Generated file. Do not edit.
buildscript {
ext.kotlin_version = '{{kotlinVersion}}'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:{{agpVersionForModule}}'
classpath 'com.android.tools.build:gradle:{{gradleVersionForModule}}'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
...
...
@@ -18,6 +20,16 @@ allprojects {
}
}
task clean(type: Delete) {
delete rootProject.buildDir
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion {{compileSdkVersion}}
defaultConfig {
minSdkVersion {{minSdkVersion}}
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
packages/flutter_tools/templates/module/android/gradle/settings.gradle.tmpl
0 → 100644
View file @
b528310f
rootProject.name = '{{projectName}}'
packages/flutter_tools/templates/module/android/gradle/src/main/AndroidManifest.xml.tmpl
0 → 100644
View file @
b528310f
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="{{androidIdentifier}}">
</manifest>
packages/flutter_tools/templates/module/android/host_app_common/app.tmpl/build.gradle.tmpl
View file @
b528310f
...
...
@@ -3,7 +3,7 @@ def flutterPluginVersion = 'managed'
apply plugin: 'com.android.application'
android {
compileSdkVersion
31
compileSdkVersion
{{compileSdkVersion}}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
...
...
@@ -12,8 +12,8 @@ android {
defaultConfig {
applicationId "{{androidIdentifier}}.host"
minSdkVersion
16
targetSdkVersion
31
minSdkVersion
{{minSdkVersion}}
targetSdkVersion
{{targetSdkVersion}}
versionCode 1
versionName "1.0"
}
...
...
packages/flutter_tools/templates/plugin/android-java.tmpl/build.gradle.tmpl
View file @
b528310f
...
...
@@ -22,7 +22,7 @@ rootProject.allprojects {
apply plugin: 'com.android.library'
android {
compileSdkVersion
31
compileSdkVersion
{{compileSdkVersion}}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
...
...
@@ -30,6 +30,6 @@ android {
}
defaultConfig {
minSdkVersion
16
minSdkVersion
{{minSdkVersion}}
}
}
packages/flutter_tools/templates/plugin/android-kotlin.tmpl/build.gradle.tmpl
View file @
b528310f
...
...
@@ -14,7 +14,7 @@ buildscript {
}
}
rootProject.
allprojects {
allprojects {
repositories {
google()
mavenCentral()
...
...
@@ -41,7 +41,7 @@ android {
}
defaultConfig {
minSdkVersion
16
minSdkVersion
{{minSdkVersion}}
}
}
...
...
packages/flutter_tools/templates/plugin_ffi/android.tmpl/build.gradle.tmpl
View file @
b528310f
...
...
@@ -27,11 +27,11 @@ apply plugin: 'com.android.library'
android {
// Bumping the plugin compileSdkVersion requires all clients of this plugin
// to bump the version in their app.
compileSdkVersion
31
compileSdkVersion
{{compileSdkVersion}}
// Bumping the plugin ndkVersion requires all clients of this plugin to bump
// the version in their app and to download a newer version of the NDK.
ndkVersion "
21.1.6352462
"
ndkVersion "
{{ndkVersion}}
"
// Invoke the shared CMake build with the Android Gradle Plugin.
externalNativeBuild {
...
...
@@ -54,6 +54,6 @@ android {
}
defaultConfig {
minSdkVersion
16
minSdkVersion
{{minSdkVersion}}
}
}
packages/flutter_tools/templates/template_manifest.json
View file @
b528310f
...
...
@@ -210,6 +210,8 @@
"templates/module/android/deferred_component/src/main/AndroidManifest.xml.tmpl"
,
"templates/module/android/gradle/build.gradle.tmpl"
,
"templates/module/android/gradle/gradle.properties.tmpl"
,
"templates/module/android/gradle/settings.gradle.tmpl"
,
"templates/module/android/gradle/src/main/AndroidManifest.xml.tmpl"
,
"templates/module/android/host_app_common/app.tmpl/build.gradle.tmpl"
,
"templates/module/android/host_app_common/app.tmpl/src/main/AndroidManifest.xml.tmpl"
,
"templates/module/android/host_app_common/app.tmpl/src/main/java/androidIdentifier/host/MainActivity.java.tmpl"
,
...
...
packages/flutter_tools/test/general.shard/android/gradle_errors_test.dart
View file @
b528310f
...
...
@@ -29,13 +29,13 @@ void main() {
permissionDeniedErrorHandler
,
flavorUndefinedHandler
,
r8FailureHandler
,
minSdkVersion
,
transformInputIssue
,
lockFileDepMissing
,
minSdkVersion
Handler
,
transformInputIssue
Handler
,
lockFileDepMissing
Handler
,
multidexErrorHandler
,
incompatibleKotlinVersionHandler
,
minCompileSdkVersionHandler
,
jvm11Required
,
jvm11Required
Handler
,
])
);
});
...
...
@@ -754,13 +754,13 @@ assembleProfile
testWithoutContext
(
'pattern'
,
()
{
expect
(
minSdkVersion
.
test
(
stdoutLine
),
minSdkVersion
Handler
.
test
(
stdoutLine
),
isTrue
,
);
});
testUsingContext
(
'suggestion'
,
()
async
{
await
minSdkVersion
.
handler
(
await
minSdkVersion
Handler
.
handler
(
line:
stdoutLine
,
project:
FlutterProject
.
fromDirectoryTest
(
globals
.
fs
.
currentDirectory
),
);
...
...
@@ -798,7 +798,7 @@ assembleProfile
group
(
'transform input issue'
,
()
{
testWithoutContext
(
'pattern'
,
()
{
expect
(
transformInputIssue
.
test
(
transformInputIssue
Handler
.
test
(
'https://issuetracker.google.com/issues/158753935'
),
isTrue
,
...
...
@@ -806,7 +806,7 @@ assembleProfile
});
testUsingContext
(
'suggestion'
,
()
async
{
await
transformInputIssue
.
handler
(
await
transformInputIssue
Handler
.
handler
(
project:
FlutterProject
.
fromDirectoryTest
(
globals
.
fs
.
currentDirectory
),
);
...
...
@@ -836,7 +836,7 @@ assembleProfile
group
(
'Dependency mismatch'
,
()
{
testWithoutContext
(
'pattern'
,
()
{
expect
(
lockFileDepMissing
.
test
(
'''
lockFileDepMissing
Handler
.
test
(
'''
* What went wrong:
Execution failed for task '
:
app:
generateDebugFeatureTransitiveDeps
'.
> Could not resolve all artifacts for configuration '
:
app:
debugRuntimeClasspath
'.
...
...
@@ -848,7 +848,7 @@ Execution failed for task ':app:generateDebugFeatureTransitiveDeps'.
});
testUsingContext
(
'suggestion'
,
()
async
{
await
lockFileDepMissing
.
handler
(
await
lockFileDepMissing
Handler
.
handler
(
project:
FlutterProject
.
fromDirectoryTest
(
globals
.
fs
.
currentDirectory
),
);
...
...
@@ -960,7 +960,7 @@ Execution failed for task ':app:checkDebugAarMetadata'.
group
(
'Java 11 requirement'
,
()
{
testWithoutContext
(
'pattern'
,
()
{
expect
(
jvm11Required
.
test
(
'''
jvm11Required
Handler
.
test
(
'''
* What went wrong:
A problem occurred evaluating project '
:
flutter
'.
> Failed to apply plugin '
com
.
android
.
internal
.
library
'.
...
...
@@ -975,7 +975,7 @@ A problem occurred evaluating project ':flutter'.
});
testUsingContext
(
'suggestion'
,
()
async
{
await
jvm11Required
.
handler
();
await
jvm11Required
Handler
.
handler
();
expect
(
testLogger
.
statusText
,
...
...
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