X Tutup
The Wayback Machine - https://web.archive.org/web/20201126220223/https://github.com/flutter/flutter/pull/70808
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate template to Gradle 6.7 and AGP 4.1.0 #70808

Merged
merged 17 commits into from Nov 20, 2020
Merged

Conversation

@blasten
Copy link
Contributor

@blasten blasten commented Nov 19, 2020

Description

Makes the plugin and the tool compatible with the latest release of AGP version, and Gradle.
Migrates the template files for apps, plugins and modules.
Migrates files in the Flutter repo.

Related Issues

Fixes #58247
Fixes #49438

Tests

I added the following tests: unit & e2e tests

Checklist

Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

@Zazo032
Copy link
Contributor

@Zazo032 Zazo032 commented Nov 19, 2020

@blasten latest available versions right now are 6.7.1 for Gradle and 4.1.1 for AGP, just in case you want to update it to latest available patch

blasten added 12 commits Nov 19, 2020
@blasten blasten force-pushed the blasten:gradle_6_0 branch from 1828721 to 5b04a4a Nov 20, 2020
@blasten blasten force-pushed the blasten:gradle_6_0 branch from 5b04a4a to 7059c8c Nov 20, 2020
@blasten blasten requested review from xster and jason-simmons Nov 20, 2020
lintOptions {
disable 'InvalidPackage'
}
compileSdkVersion 30

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

this is ok but just for my understanding, this is orthogonal to a agp move right?

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

that's true

@@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
android.enableR8=true

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

can you elaborate? Or is this just to save time since no one is shipping it?

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

R8 has become the default in this AGP version. Having this causes a warning.

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

got it, thanks

import io.flutter.plugins.GeneratedPluginRegistrant;

public class MainActivity extends FlutterActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeneratedPluginRegistrant.registerWith(this);
new MethodChannel(getFlutterView(), "flavor").setMethodCallHandler(new MethodChannel.MethodCallHandler() {

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

related?

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

it's a small clean up. This isn't used by the test, and was causing some warnings.

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

ok

Copy link
Contributor

@xster xster left a comment

woohoo! Amazing

// This way, custom Proguard rules can be configured as needed.
proguardFiles project.android.getDefaultProguardFile("proguard-android.txt"), flutterProguardRules, "proguard-rules.pro"
}
String flutterProguardRules = Paths.get(flutterRoot.absolutePath, "packages", "flutter_tools",

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

is that what the enable r8 thing is? We're just making it unconditional?

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

This is one is about removing the need to make this conditional via a Flutter tool flag. That isn't needed. Users shouldn't disable this in release, but if they really want, they can always do it in build.gradle.

String flutterProguardRules = Paths.get(flutterRoot.absolutePath, "packages", "flutter_tools",
"gradle", "flutter_proguard_rules.pro")
project.android.buildTypes {
release {

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

what levers are we giving for custom build types?

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

levers?

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

when users create custom types, we should document what the right approach is to have the correct default settings associated. e.g. recommend

production {
     initWith release         
}

rather than making one from scratch

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

I don't think we are doing anything special, other than profile.

release is an official build type provided by the Android plugin. I think the Flutter docs can link to https://developer.android.com/studio/build/build-variants.

return target
}

// In AGP 4.0, the Android linter task depends on all the JAR tasks containing `libapp.so`.

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

Didn't understand this sentence :)

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

I changed the sentence a bit. #58247 (comment)

// 3. Otherwise, the equivalent Flutter variant is `release`.
String variantBuildMode = buildModeFor(libraryVariant.buildType)
if (buildModeFor(appProjectVariant.buildType) != variantBuildMode) {
return

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

Can we print a message here? I always found the mismatch error a bit cryptic.

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

This is during configuration phase. It could be quite spammy, and not very meaningful for debugging. What's the user story?

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

Maybe I'm thinking of something else. In Android Studio, open build variants tab in case of gradle subproject integration, pick one variant for the app and another variant for the flutter module.

'To learn more, see: https://developer.android.com/studio/build/shrink-code',
);
hide: true,
help: 'This flag is deprecated.'

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

Describe a bit more what now happens

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

Done.

@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

can we add another test to make sure the whole thing builds with gradle 5 / agp 3?

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

that is already the case in the customer tests

This comment has been minimized.

@xster

xster Nov 20, 2020
Contributor

which customer tests are you referring to?

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

https://github.com/flutter/tests/tree/master/registry - Although, it looks like we don't build apk in any of those. I will add one that does it.

This comment has been minimized.

@blasten

blasten Nov 20, 2020
Author Contributor

Filed #70964. Gradle 5.* is currently tested by building the Flutter Gallery demo app.

@xster
Copy link
Contributor

@xster xster commented Nov 20, 2020

@csells could be worth calling this out on the next stable blog

@blasten blasten requested a review from xster Nov 20, 2020
@xster
xster approved these changes Nov 20, 2020
Copy link
Contributor

@xster xster left a comment

LGTM 🤞

@blasten blasten merged commit 8e73bab into flutter:master Nov 20, 2020
71 checks passed
71 checks passed
Google testing Google testing passed!
Details
Linux analyze
Details
Linux build_aar_module_test
Details
Linux build_gallery
Details
Linux build_tests
Details
Linux customer_testing
Details
Linux docs
Details
Linux firebase_abstract_method_smoke_test
Details
Linux firebase_android_embedding_v2_smoke_test
Details
Linux firebase_release_smoke_test
Details
Linux framework_tests
Details
Linux fuchsia_precache
Details
Linux gradle_non_android_plugin_test
Details
Linux gradle_plugin_bundle_test
Details
Linux gradle_plugin_fat_apk_test
Details
Linux gradle_plugin_light_apk_test
Details
Linux module_custom_host_app_name_test
Details
Linux module_host_with_custom_build_test
Details
Linux module_test
Details
Linux plugin_test
Details
Linux tool_tests
Details
Linux web_benchmarks_html
Details
Linux web_e2e_test
Details
Linux web_integration_tests
Details
Linux web_long_running_tests
Details
Linux web_smoke_test
Details
Linux web_tests
Details
Linux web_tool_tests
Details
Mac build_aar_module_test
Details
Mac build_gallery
Details
Mac build_ios_framework_module_test
Details
Mac build_tests
Details
Mac customer_testing
Details
Mac framework_tests
Details
Mac gradle_non_android_plugin_test
Details
Mac gradle_plugin_bundle_test
Details
Mac gradle_plugin_fat_apk_test
Details
Mac gradle_plugin_light_apk_test
Details
Mac module_custom_host_app_name_test
Details
Mac module_host_with_custom_build_test
Details
Mac module_test
Details
Mac module_test_ios
Details
Mac plugin_lint_mac
Details
Mac plugin_test
Details
Mac tool_tests
Details
WIP Ready for review
Details
Windows build_aar_module_test
Details
Windows build_tests
Details
Windows customer_testing
Details
Windows framework_tests
Details
Windows gradle_non_android_plugin_test
Details
Windows gradle_plugin_bundle_test
Details
Windows gradle_plugin_light_apk_test
Details
Windows module_custom_host_app_name_test
Details
Windows module_host_with_custom_build_test
Details
Windows module_test
Details
Windows plugin_test
Details
Windows tool_tests
Details
analyze-linux Task Summary
Details
cla/google All necessary CLAs are signed
customer_testing-linux Task Summary
Details
docs-linux Task Summary
Details
flutter-build
Details
flutter-gold All golden file tests have passed.
Details
framework_tests-libraries-linux Task Summary
Details
framework_tests-misc-linux Task Summary
Details
framework_tests-widgets-linux Task Summary
Details
tool_tests-commands-linux Task Summary
Details
tool_tests-general-linux Task Summary
Details
web_integration_tests Task Summary
Details
web_smoke_test Task Summary
Details
@blasten blasten deleted the blasten:gradle_6_0 branch Nov 20, 2020
@amirh
Copy link
Member

@amirh amirh commented Nov 23, 2020

This broke flutter/plugins, see: https://cirrus-ci.com/task/6538283054268416

Cirrus CI Remove

00:03 clone
01:29 upgrade
00:04 activate
01:43 main

BUILD FAILED in 1m 25s
Running Gradle task 'assembleDebug'...                             85.9s
Gradle task assembleDebug failed with exit code 1
Failed to build debug all_plugins app.
There was a failure to compile all first party plugins together, but there were no changes detected in packages.
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...                        


FAILURE: Build failed with an exception.



* Where:

Build file '/tmp/cirrus-ci-build/all_plugins/android/build.gradle' line: 24



* What went wrong:

A problem occurred evaluating root project 'android'.

> A problem occurred configuring project ':app'.

   > Failed to notify project evaluation listener.

      > org.gradle.api.file.ProjectLayout.directoryProperty(Lorg/gradle/api/provider/Provider;)Lorg/gradle/api/file/DirectoryProperty;



* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.



* Get more help at https://help.gradle.org



BUILD FAILED in 721ms
Running Gradle task 'assembleRelease'...                         1,169ms
Gradle task assembleRelease failed with exit code 1
Failed to build release all_plugins app.
There was a failure to compile all first party plugins together, but there were no changes detected in packages.

Exit status: 2

amirh added a commit that referenced this pull request Nov 23, 2020
This reverts commit 8e73bab.
amirh added a commit that referenced this pull request Nov 23, 2020
This reverts commit 8e73bab.
@gustav3d
Copy link

@gustav3d gustav3d commented Nov 23, 2020

So instead of fiximg the boken plugin https://cirrus-ci.com/task/6538283054268416

Cirrus CI Remove

00:03 clone
01:29 upgrade
00:04 activate
01:43 main

BUILD FAILED in 1m 25s
Running Gradle task 'assembleDebug'...                             85.9s
Gradle task assembleDebug failed with exit code 1
Failed to build debug all_plugins app.
There was a failure to compile all first party plugins together, but there were no changes detected in packages.
You are building a fat APK that includes binaries for android-arm, android-arm64, android-x64.
If you are deploying the app to the Play Store, it's recommended to use app bundles or split the APK to reduce the APK size.
    To generate an app bundle, run:
        flutter build appbundle --target-platform android-arm,android-arm64,android-x64
        Learn more: https://developer.android.com/guide/app-bundle
    To split the APKs per ABI, run:
        flutter build apk --target-platform android-arm,android-arm64,android-x64 --split-per-abi
        Learn more: https://developer.android.com/studio/build/configure-apk-splits#configure-abi-split
Running Gradle task 'assembleRelease'...                        


FAILURE: Build failed with an exception.



* Where:

Build file '/tmp/cirrus-ci-build/all_plugins/android/build.gradle' line: 24



* What went wrong:

A problem occurred evaluating root project 'android'.

> A problem occurred configuring project ':app'.

   > Failed to notify project evaluation listener.

      > org.gradle.api.file.ProjectLayout.directoryProperty(Lorg/gradle/api/provider/Provider;)Lorg/gradle/api/file/DirectoryProperty;



* Try:

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.



* Get more help at https://help.gradle.org



BUILD FAILED in 721ms
Running Gradle task 'assembleRelease'...                         1,169ms
Gradle task assembleRelease failed with exit code 1
Failed to build release all_plugins app.
There was a failure to compile all first party plugins together, but there were no changes detected in packages.

Exit status: 2
, you revert this?!

@amirh
Copy link
Member

@amirh amirh commented Nov 23, 2020

@gustav3d per https://github.com/flutter/flutter/wiki/Tree-hygiene if a commit breaks a tree it should be first reverted, no questions asked, then it should be re-landed with the issue figured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.
X Tutup