Repository navigation
Description
Summary
Since Flutter 3.50, an Android app that uses at least one plugin fails to configure, even for flutter run in debug mode, if any of its build types sets a property that AGP does not allow in a library module. Flutter 3.47.9 builds the same app.
#196412 reports the applicationIdSuffix case. This issue tracks the other affected properties:
| Build type property in the app | Error AGP reports in the plugin's library module |
|---|---|
isShrinkResources = true (for example, on a custom build type) |
Resource shrinker cannot be used for libraries. |
buildConfigField(...) |
... contains custom BuildConfig fields, but the feature is disabled |
resValue(...) |
... contains custom resource values, but the feature is disabled |
Steps to reproduce
flutter create repro && cd repro && flutter pub add shared_preferences- In
android/app/build.gradle.kts, add a build type that the plugin doesn't define. Use any one of these cases:android { // AGP 9 turns these features off by default. Cases 2 and 3 need them, or the app module rejects its own fields. buildFeatures { buildConfig = true; resValues = true } buildTypes { create("staging") { // Case 1: copying release is enough. Flutter's release build type sets // isMinifyEnabled = true and isShrinkResources = true, so staging gets them too. initWith(getByName("release")) // Case 2 (instead of initWith): buildConfigField("String", "ENV", "\"staging\"") // Case 3 (instead of initWith): resValue("string", "env_name", "staging") } } } - Run
flutter build apk --debug.
Expected: the build succeeds, as it does on 3.47.9.
Actual: configuring a plugin library module (for example :jni) fails with the error in the table above.
This means that any custom build type that uses initWith(getByName("release")) breaks on 3.50, even if it doesn't set isShrinkResources itself.
Cause
#191606 creates each app build type that a plugin lacks on that plugin with initWith(appBuildType). AGP's initWith copies every build type property, including the ones that AGP rejects in a library. The isShrinkResources check runs inside initWith, so the value can't be cleared afterwards.
Workaround
Define the build type in each library subproject (verified on stock 3.50.0 for all three cases) before Flutter copies it. Add this to the root android/build.gradle.kts:
subprojects {
pluginManager.withPlugin("com.android.library") {
extensions.configure<com.android.build.api.dsl.LibraryExtension>("android") {
buildTypes.maybeCreate("staging")
}
}
}
Activity
[-][Android] 3.50 regression: app build types with isShrinkResources, buildConfigField or resValue break builds that use plugins[/-][+][Android] 3.50 regression: custom build types (initWith(release), isShrinkResources, buildConfigField, resValue) break builds that use plugins[/+]reidbaker-agent commentedon Nov 16, 2026
While fixing this, we found one more 3.50 failure mode with the same cause, and #196692 fixes it too. With the shrinker error out of the way,
staging { initWith(getByName("release")) }then failed at R8 withMissing class io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin. Flutter copiedisMinifyEnabledonto the plugin's library build type, so R8 minified the plugin without its keep rules. #196692 stops copyingisMinifyEnabledto library plugins. The app's own R8 run still shrinks plugin code.[flutter_tools] Do not copy app-only build type properties onto libra…
[stable] [flutter_tools] Do not copy app-only build type properties o…
[beta] [flutter_tools] Do not copy app-only build type properties ont…
[stable] [flutter_tools] Do not copy app-only build type properties o…