Skip to content

[Android] --split-per-abi gives every split APK the same versionCode when versionCode is set only in AndroidManifest.xml (3.50 regression) #196559

Closed

Description

@reidbaker-agent

What happens

If an app sets android:versionCode only in AndroidManifest.xml (no versionCode in the android {} block, which is common in older projects), flutter build apk --split-per-abi on 3.50 gives every split APK the same versionCode. Google Play won't accept multiple APKs with the same versionCode. The build still succeeds and only prints a warning:

Flutter could not give each split APK of variant 'release' a distinct versionCode because its android {} block declares no versionCode, so Google Play will not accept these APKs together.

Before 3.50, Flutter offset the manifest versionCode for each ABI.

Impact

This came from #193693. The PR description listed "a versionCode declared only in the manifest is not offset" as a trade-off (#193693 (comment)), but neither the reviewers nor the Android team realized the implication that this would produce split APKs that had non unique version numbers which we know Google Play rejects. Reviewers asked for the message to be shown to users (#193693 (comment), commit 25550b3), and it stayed a non-fatal log message. No test checks the versionCodes in the manifest-only case.

Workaround

In android/app/build.gradle(.kts), set versionCode in defaultConfig, for example versionCode = flutter.versionCode (or the literal value). Then remove android:versionCode from AndroidManifest.xml. Each split APK then gets its ABI offset again. Verified on master 319ffb4: with a literal versionCode = 7, the APKs are arm64 2007, armv7 1007, x86_64 4007; with flutter.versionCode and build number 1, they are 2001/1001/4001. Neither build printed the warning.

Steps to reproduce

  1. flutter create app and remove versionCode = flutter.versionCode from defaultConfig in android/app/build.gradle.kts.
  2. Add android:versionCode="7" to the <manifest> element in android/app/src/main/AndroidManifest.xml.
  3. Run flutter build apk --release --split-per-abi.
  4. For each APK in build/app/outputs/flutter-apk/, run aapt2 dump badging <apk> | grep versionCode.
arm64-v8a armeabi-v7a x86_64
Before #193693 (557f863) 2007 1007 4007
master / 3.50 7 7 7

Cause

#193693 (AGP 9.1 migration #7, part of #180137) moved the per-ABI versionCode onto the variant API: output.versionCode.set(abi * 1000 + <DSL versionCode>) in FlutterPlugin.kt (around line 701). The variant API only sees the DSL versionCode, not the manifest one, so manifest-only projects get no offset.

Requirements for the fix

The fix must keep the AGP public-API migration working. A split build with a manifest-only versionCode must produce distinct versionCodes in an app with android.newDsl=true and android.builtInKotlin=true in gradle.properties, with no reads through the legacy variant API at configuration time. Simply restoring the 3.47 code (which read output.versionCode, including the merged manifest value, through the legacy API) would undo the migration, so it's ruled out.

Options

  1. Keep the DSL path. When the DSL sets no versionCode, set output.versionCode to a lazy provider that reads android:versionCode from the variant's manifest sources (public variant.sources API) at execution time. This restores 3.47's results without legacy reads. It needs verification under newDsl=true / builtInKotlin=true and the configuration cache.
  2. Fail --split-per-abi builds when no base versionCode can be resolved, with a message that tells users to set versionCode in defaultConfig. This is simple and safe for a cherry-pick, but users still have to change their projects.
  3. A migrator that moves the manifest versionCode into defaultConfig.

Option 1 is preferred if it works within the requirements above. Option 2 is the fallback, and either one could be combined with option 3. Found while auditing the AGP 9 migration stack for #196444.

Activity

  1. self-assigned this
    on Nov 13, 2026
  2. added
    team-android
    found in release: 3.50
    c: regression
    on Nov 13, 2026
  3. sidhant947 commented on Nov 14, 2026

    @sidhant947

    App version code is adding 10000 for all of my builds in latest version , they have just fucked most of my apps

  4. mboetger commented on Nov 16, 2026

    @mboetger
    Contributor

    App version code is adding 10000 for all of my builds in latest version , they have just fucked most of my apps

    @sidhant947 sorry for the disruption. To disable this, add this line to android/gradle.properties (or pass -Pforce-version-code-ignoring-abi=true to flutter build):

    force-version-code-ignoring-abi=true
    

    With that property set, Flutter leaves versionCode untouched during --split-per-abi, so your existing Gradle versionCode logic sees your base versionCode again without +1000.

    If that does not fix your issue, please file another issue.

  5. sidhant947 commented on Nov 16, 2026

    @sidhant947

    Actually i did tried it , but it was still jumping to numbers which aren't understandable , see sidhant947/Mahjong#11 , For now sidhant947/Mahjong@08bd3d5 I have opted for a native versioncode flow for now , hopefully it stablized in upcoming updates , I choose flutter for stability , not for surprises every month

  6. sidhant947 commented on Nov 16, 2026

    @sidhant947

    Also why such an important detail that you have "enabled by Default" wasn't in release note or breaking changes , not even mention of it anywhere https://flutter.dev/blog/whats-new-in-flutter-3-50 https://docs.flutter.dev/release/breaking-changes , like seriously , why not even 1 mention of this ? is team was sleeping and just decided , it isn't something important , i read through before migrating to 3.50.0 , I thought i have gone through everything

  7. reidbaker commented on Nov 16, 2026

    @reidbaker
    Member

    Hey person responsible for the change here. Most people ship with app bundles which are unaffected and there is a website pull request that didnt land in sync with the release. I am working on it today which describes some of the issue. The reason for this change is that Android is requiring that all android tooling move over to a new api for building apps. That new api does not have any way to keep the old behavior and not migrating to this new api will break all flutter apps in the near future.

    I debated removing the flag and feature since we could not support it without a change and decided that a different version code was better than a broken feature. I am open to feedback that the correct action should have been to remove the flag with no replacement or deprecation warning.

  8. mboetger commented on Nov 16, 2026

    @mboetger
    Contributor

    Actually i did tried it , but it was still jumping to numbers which aren't understandable , see sidhant947/Mahjong#11 , For now sidhant947/Mahjong@08bd3d5 I have opted for a native versioncode flow for now , hopefully it stablized in upcoming updates , I choose flutter for stability , not for surprises every month

    Ah, I think you would have been ok if you hadn't changed off the flutter.versionCode and only used the flag in your fix. But I'm glad you figured something out.

  9. sidhant947 commented on Nov 16, 2026

    @sidhant947

    Most people ship with app bundles which are unaffected

    That's not good to do whataboutism about it . I know many people on flutter nowadays uses ai and most of them don't care much about such things at all. But for me who have been following flutter a lot and i have consistency in releases pattern to follow same pattern among all of my fdroid apps , due to no prior information about such automatic action , my versioncode have jumped to 10k from being 160 , later issues came up in reproducibilty of my builds as my releases had 10071 10072 10073 , but on fdroid it came 10071 20072 40073 , both build ran from same commit and same flutter 3.50.0 .

    "flag or deprecation warning" for such event should have given prior a stable release , there was plenty of time

  10. reidbaker commented on Nov 16, 2026

    @reidbaker
    Member

    @sidhant947 here is the website pr that is in progress if you want to point your agent at it to see if there are any other cases that impact your app. flutter/website#14053

  11. added a commit that references this issue on Nov 18, 2026
    a61f510
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

c: regressionfound in release: 3.50team-android

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions