Skip to content

[Android] 3.50 regression: custom build types (initWith(release), isShrinkResources, buildConfigField, resValue) break builds that use plugins #196696

Closed

Description

@reidbaker-agent

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

  1. flutter create repro && cd repro && flutter pub add shared_preferences
  2. 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")
            }
        }
    }
  3. 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")
        }
    }
}

Fix: #196692. Part of #196689.

Activity

  1. changed the title [-][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[/+] on Nov 16, 2026
  2. reidbaker-agent commented on Nov 16, 2026

    @reidbaker-agent
    ContributorAuthor

    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 with Missing class io.flutter.plugins.sharedpreferences.SharedPreferencesPlugin. Flutter copied isMinifyEnabled onto the plugin's library build type, so R8 minified the plugin without its keep rules. #196692 stops copying isMinifyEnabled to library plugins. The app's own R8 run still shrinks plugin code.

  3. added
    in triage
    on Nov 17, 2026
  4. removed
    in triage
    on Nov 17, 2026
  5. added a commit that references this issue on Nov 17, 2026
    534fb4d
  6. added
    c: regression
    platform-android
    tool
    t: gradle
    r: fixed
    team-android
    found in release: 3.50
    has reproducible steps
    on Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: regressionfound in release: 3.50has reproducible stepsplatform-androidr: fixedt: gradleteam-androidtool

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions