mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[CP-stable] Cherry pick "Fix flutter build aar for modules that use a plugin" (#154944)
Sum of changes is: cherry pick of https://github.com/flutter/flutter/pull/154757 Merge manual application of of https://github.com/flutter/flutter/pull/154945 manual application of https://github.com/flutter/flutter/pull/154967 Copied form below from automatic label (this is a cherry pick of https://github.com/flutter/flutter/pull/154757). ### Issue Link: What is the link to the issue this cherry-pick is addressing? Fixes https://github.com/flutter/flutter/issues/154371. ### Changelog Description: Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples Fixes a crash when building Flutter modules for android with `flutter build aar`, when using Android Gradle Plugin 8.0+. ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch) Fixes the mentioned crash when building a module as an aar with Android Gradle Plugin 8.0+. ### Workaround: Is there a workaround for this issue? No. ### Risk: What is the risk level of this cherry-pick? ### Test Coverage: Are you confident that your fix is well-tested by automated tests? ### Validation Steps: What are the steps to validate that this fix works? Build a module: 1. `flutter create foobar --template=module` 2. `cd foobar` 3. Edit the `.android/build.gradle` to use AGP 8.1. 4. `flutter run`/`flutter build aar`
This commit is contained in:
parent
98ba471ea2
commit
6553713e4a
21
.ci.yaml
21
.ci.yaml
@ -356,6 +356,27 @@ targets:
|
||||
task_name: android_views
|
||||
timeout: 60
|
||||
|
||||
- name: Linux build_aar_module_test
|
||||
bringup: true
|
||||
recipe: devicelab/devicelab_drone
|
||||
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": "open_jdk", "version": "version:17"}
|
||||
]
|
||||
tags: >
|
||||
["devicelab","hostonly"]
|
||||
task_name: build_aar_module_test
|
||||
runIf:
|
||||
- dev/**
|
||||
- packages/flutter_tools/**
|
||||
- bin/**
|
||||
- .ci.yaml
|
||||
|
||||
- name: Linux build_tests_1_3
|
||||
recipe: flutter/flutter_drone
|
||||
timeout: 60
|
||||
|
||||
@ -65,7 +65,6 @@ Future<void> main() async {
|
||||
' path: ../plugin_with_android$platformLineSep'
|
||||
' plugin_without_android:$platformLineSep'
|
||||
' path: ../plugin_without_android$platformLineSep'
|
||||
' webcrypto: 0.5.2$platformLineSep', // Plugin that uses NDK.
|
||||
);
|
||||
modulePubspec.writeAsStringSync(content, flush: true);
|
||||
|
||||
|
||||
@ -116,6 +116,39 @@ allprojects {
|
||||
apply plugin: "maven-publish"
|
||||
}
|
||||
|
||||
afterProject { project ->
|
||||
// Exit early if either:
|
||||
// 1. The project doesn't have the Android Gradle plugin applied.
|
||||
// 2. The project has already defined which variants to publish (trying to re-define which
|
||||
// variants to publish will result in an error).
|
||||
if (!project.hasProperty("android")) {
|
||||
return
|
||||
}
|
||||
if (project.android.publishing.singleVariants.size() != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
Closure addSingleVariants = {buildType ->
|
||||
if (!project.android.productFlavors.isEmpty()) {
|
||||
project.android.productFlavors.all{productFlavor ->
|
||||
project.android.publishing.singleVariant(
|
||||
productFlavor.name + buildType.name.capitalize()
|
||||
) {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
project.android.publishing.singleVariant(buildType.name) {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
project.android.buildTypes.all(addSingleVariants)
|
||||
}
|
||||
|
||||
projectsEvaluated {
|
||||
assert rootProject.hasProperty("is-plugin")
|
||||
if (rootProject.property("is-plugin").toBoolean()) {
|
||||
|
||||
@ -51,6 +51,7 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
flutter {
|
||||
source = "../.."
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user