Skip to content

Conversation

@gmackall
Copy link
Member

@gmackall gmackall commented Sep 6, 2024

#151675 bumped module templates to AGP 8.1.

In doing so, I tried to work around a behavior change that was new in AGP 8.0:

AGP 8.0 creates no SoftwareComponent by default. Instead AGP creates SoftwareComponents only for variants that are configured to be published using the publishing DSL.

by using AGP's publishing DSL to define which variants to publish in the module's ephemeral gradle files:

android.buildTypes.all {buildType ->
    if (!android.productFlavors.isEmpty()) {
        android.productFlavors.all{productFlavor ->
            android.publishing.singleVariant(productFlavor.name + buildType.name.capitalize()) {
                withSourcesJar()
                withJavadocJar()
            }
        }
    } else {
        android.publishing.singleVariant(buildType.name) {
            withSourcesJar()
            withJavadocJar()
        }
    }
}

The problem is that this doesn't get applied to the plugin projects used by the module, so if a module uses any plugin it breaks. This PR fixes that by applying similar logic, but to each project (not just the module's project).

Tested manually with https://github.com/gmackall/GrayAddToApp, and also re-enabled an old test that tested this use case as a part of the PR.

Fixes: #154371

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Sep 6, 2024
@gmackall
Copy link
Member Author

gmackall commented Sep 6, 2024

cc @reidbaker , wip here (ignore if you're already out for the day!)

@reidbaker
Copy link
Contributor

Given this area is of high consequence to customers and cleary difficult for us to understand the full impact lets add a test.

I think a more unit style tests where we run gradle tasks and verify the output contains the tasks we expect could be good enough but would be a new style of test. Or you could add an integration test of a module that had a plugin and confirmed we could build an aar without error. Or both.

@gmackall
Copy link
Member Author

gmackall commented Sep 9, 2024

Did some manual testing, because I wanted to be sure this was really working.

Followed the docs at https://docs.flutter.dev/add-to-app/android/add-flutter-screen to get a super rough add to app setup going at https://github.com/gmackall/GrayAddToApp that has a host app and a module that uses a plugin, and made sure that the built aar actually works when added as a screen to a host app.

Going to work on adding the test now

@gmackall
Copy link
Member Author

gmackall commented Sep 10, 2024

Turns out we already had a test that tested this, it was just disabled 🙂

The reason for disabling seems to be either a flake getting the kotlin gradle plugin, or otherwise a larger problem with the third party webcrypto plugin that the test was using. I just removed that plugin - it isn't important for our case (the test already uses a different plugin, the webcrypto one is just to additionally test a plugin that uses the ndk).

The test passed for me locally, so I've re-enabled it (as bringup).

@gmackall gmackall marked this pull request as ready for review September 10, 2024 00:58
@gmackall gmackall requested a review from a team September 10, 2024 00:58
@reidbaker
Copy link
Contributor

Turns out we already had a test that tested this, it was just disabled 🙂

The reason for disabling seems to be either a flake getting the kotlin gradle plugin, or otherwise a larger problem with the third party webcrypto plugin that the test was using. I just removed that plugin - it isn't important for our case (the test already uses a different plugin, the webcrypto one is just to additionally test a plugin that uses the ndk).

I the test passed for me locally, so I've re-enabled it (as bringup).

@gmackall can you post a link to the pr that disabled this test?

@gmackall
Copy link
Member Author

#102329

@gmackall gmackall added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 10, 2024
@auto-submit auto-submit bot merged commit f964f15 into flutter:master Sep 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 10, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 10, 2024
@gmackall gmackall added the cp: stable cherry pick this pull request to stable release candidate branch label Sep 10, 2024
@flutteractionsbot
Copy link

Failed to create CP due to merge conflicts.
You will need to create the PR manually. See the cherrypick wiki for more info.

engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 11, 2024
auto-submit bot pushed a commit that referenced this pull request Sep 11, 2024
… a plugin" (#154944)

Sum of changes is:
cherry pick of #154757
Merge
manual application of of #154945
manual application of #154967

Copied form below from automatic label (this is a cherry pick of #154757).

### Issue Link:
What is the link to the issue this cherry-pick is addressing?

Fixes #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`
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Sep 12, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Sep 12, 2024
Roll Flutter from 2e221e7 to 303f222 (77 revisions)

flutter/flutter@2e221e7...303f222

2024-09-12 [email protected] Manual roll to 48ddaf578fb0c8326d5b4b680b0f49ea72e33216 (flutter/flutter#155070)
2024-09-12 [email protected] Externalize and update onboarding instructions (flutter/flutter#154730)
2024-09-12 [email protected] when setting up the log reader for a device during `flutter run`, discard any `RPCError` thrown due to the device being disconnected (flutter/flutter#155049)
2024-09-12 98614782+auto-submit[bot]@users.noreply.github.com Reverts "iOS: update provisioning profile for 2024-2025 cert (#155052)" (flutter/flutter#155059)
2024-09-12 [email protected] iOS: update provisioning profile for 2024-2025 cert (flutter/flutter#155052)
2024-09-11 [email protected] Factor out `Container` objects (flutter/flutter#153619)
2024-09-11 [email protected] Move (`dev/tools`), complete v0 of `native_driver` (Android) (flutter/flutter#154843)
2024-09-11 [email protected] Roll Flutter Engine from ade8ef293bc6 to ee5adf6d2ee1 (2 revisions) (flutter/flutter#155046)
2024-09-11 [email protected] Fix `flutter run` on Mac x64 hosts if Swift Package Manager is enabled (flutter/flutter#154645)
2024-09-11 [email protected] Roll Packages from bb53e5d to 4c18648 (1 revision) (flutter/flutter#155033)
2024-09-11 [email protected] Roll Flutter Engine from 4eb729b7a5c4 to ade8ef293bc6 (3 revisions) (flutter/flutter#155031)
2024-09-11 [email protected] fix: Dropdown menu trying to access highlight element which doesn't exist when search and filters both are enabled (flutter/flutter#151969)
2024-09-11 [email protected] Marks Linux build_tests_3_5 to be unflaky (flutter/flutter#154993)
2024-09-11 [email protected] Add 'direction' allow to 'SegmentedButton' oriented vertically (flutter/flutter#150903)
2024-09-11 [email protected] Marks Linux build_tests_5_5 to be unflaky (flutter/flutter#154995)
2024-09-11 [email protected] Update the signature of DDS launcher callback. (flutter/flutter#154949)
2024-09-11 [email protected] Migrate Color.toString() test, improves `equalsIgnoringHashCodes` (flutter/flutter#154934)
2024-09-11 [email protected] Update material and cupertino localizations (flutter/flutter#154959)
2024-09-11 [email protected] Marks Linux build_tests_1_5 to be unflaky (flutter/flutter#154991)
2024-09-11 [email protected] Marks Linux build_tests_2_5 to be unflaky (flutter/flutter#154992)
2024-09-11 [email protected] Fix `flutter create` warning regarding Java compatibility (flutter/flutter#152836)
2024-09-11 [email protected] Roll Flutter Engine from 54757dab9462 to 4eb729b7a5c4 (1 revision) (flutter/flutter#155022)
2024-09-11 [email protected] Fix java version used by `build_aar_module_test` (flutter/flutter#154967)
2024-09-11 [email protected] Roll Flutter Engine from 0a14c519ea4f to 54757dab9462 (1 revision) (flutter/flutter#155015)
2024-09-11 [email protected] Roll Flutter Engine from 35a3171b72c5 to 0a14c519ea4f (1 revision) (flutter/flutter#154984)
2024-09-11 [email protected] Roll Flutter Engine from b9c0b96c3316 to 35a3171b72c5 (1 revision) (flutter/flutter#154980)
2024-09-11 [email protected] Roll Flutter Engine from 52eeea075767 to b9c0b96c3316 (1 revision) (flutter/flutter#154976)
2024-09-11 [email protected] Roll Flutter Engine from a26075f9b1e6 to 52eeea075767 (1 revision) (flutter/flutter#154973)
2024-09-11 [email protected] Roll Flutter Engine from 60c15bc0f40e to a26075f9b1e6 (6 revisions) (flutter/flutter#154969)
2024-09-11 [email protected] Migrate `apple-mobile-web-*` to `mobile-web-*`. (flutter/flutter#154964)
2024-09-11 [email protected] Roll Flutter Engine from 8a038a6f7099 to 60c15bc0f40e (15 revisions) (flutter/flutter#154960)
2024-09-10 [email protected] Adds dart fixes for Color opacity functions (flutter/flutter#154953)
2024-09-10 [email protected] Missing benchmarks for `foundation/all_elements_bench.dart` (flutter/flutter#154954)
2024-09-10 [email protected] Update color assertions (flutter/flutter#154752)
2024-09-10 [email protected] handle EAGAIN (macOS) in ErrorHandlingProcessManager (flutter/flutter#154306)
2024-09-10 [email protected] fix unpack freezing app with animation duration zero  (flutter/flutter#153890)
2024-09-10 [email protected] Remove last `--disable-dart-dev` in `flutter/flutter`. (flutter/flutter#154948)
2024-09-10 [email protected] Remove scheduler: luci from new `build_aar_module_test` (flutter/flutter#154945)
2024-09-10 [email protected] Roll pub packages (flutter/flutter#154939)
2024-09-10 [email protected] `CupertinoSlidingSegmentedControl` update (flutter/flutter#152976)
2024-09-10 [email protected] Roll pub packages (flutter/flutter#154933)
2024-09-10 [email protected] fix test `chrome.close can recover if getTab throws a StateError` (flutter/flutter#154889)
2024-09-10 [email protected] SearchBar context menu (flutter/flutter#154833)
2024-09-10 [email protected] Fix `flutter build aar` for modules that use a plugin (flutter/flutter#154757)
2024-09-10 [email protected] Roll Packages from b4e0fc1 to bb53e5d (4 revisions) (flutter/flutter#154926)
2024-09-10 [email protected] Clean up `SnackBar` inherit theme data test (flutter/flutter#154921)
...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App cp: stable cherry pick this pull request to stable release candidate branch tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem when running "flutter build aar" using AGP 8.1 + JDK 17

3 participants