-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Migrate template to Gradle 6.7 and AGP 4.1.0 #70808
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
Conversation
@blasten latest available versions right now are |
lintOptions { | ||
disable 'InvalidPackage' | ||
} | ||
compileSdkVersion 30 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is ok but just for my understanding, this is orthogonal to a agp move right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's true
@@ -1,4 +1,3 @@ | |||
org.gradle.jvmargs=-Xmx1536M | |||
android.useAndroidX=true | |||
android.enableJetifier=true | |||
android.enableR8=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you elaborate? Or is this just to save time since no one is shipping it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
R8 has become the default in this AGP version. Having this causes a warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
related?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a small clean up. This isn't used by the test, and was causing some warnings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that what the enable r8 thing is? We're just making it unconditional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what levers are we giving for custom build types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
levers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't understand this sentence :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we print a message here? I always found the mismatch error a bit cryptic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is during configuration phase. It could be quite spammy, and not very meaningful for debugging. What's the user story?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Describe a bit more what now happens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add another test to make sure the whole thing builds with gradle 5 / agp 3?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that is already the case in the customer tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which customer tests are you referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #70964. Gradle 5.* is currently tested by building the Flutter Gallery demo app.
@csells could be worth calling this out on the next stable blog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🤞
This broke flutter/plugins, see: https://cirrus-ci.com/task/6538283054268416 |
So instead of fiximg the boken plugin https://cirrus-ci.com/task/6538283054268416, you revert this?! |
@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. |
This reverts commit 7df04fd.
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.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.