Skip to content

[Android] Flutter 3.35.1 cannot customize the version code during compilation. #173917

@mumu-lhl

Description

@mumu-lhl

Steps to reproduce

Add this code to build.gradle.kts:

val abiCodes = mapOf("x86_64" to 1, "armeabi-v7a" to 2, "arm64-v8a" to 3, "universal" to 4)

androidComponents {
    onVariants { variant ->

        variant.outputs.forEach { output ->
            val name = output.filters.find { it.filterType == ABI }?.identifier

            val baseAbiCode = abiCodes[name ?: "universal"]
            if (baseAbiCode != null) {
                output.versionCode.set(output.versionCode.get() * 10000 + baseAbiCode * 1000)
            }
        }
    }
}

It works fine in Flutter 3.32.X, but not in 3.35.X. This issue is suspected to be caused by #169816.

Expected results

Version code for each arch:

  • x86_64 - XX1000
  • armeabi-v7a - XX2000
  • arm64-v8a - XX3000
  • universal - XX4000

Since the format XX[version code] is required by F-Droid, I hope there is a solution that can achieve this.

Actual results

Version code for each arch:

  • x86_64 - 40xx
  • armeabi-v7a - 10XX
  • arm64-v8a - 20XX

Code sample

Same as above.

Screenshots or Video

Logs

Flutter Doctor output

It doesn't matter.

Metadata

Metadata

Assignees

Labels

P0Critical issues such as a build break or regressionc: regressionIt was better in the past than it is nowcp: betacherry pick this pull request to beta release candidate branchcp: stablecherry pick this pull request to stable release candidate branchfound in release: 3.33Found to occur in 3.33found in release: 3.35Found to occur in 3.35fyi-toolFor the attention of Flutter Tool teamhas reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: gradle"flutter build" and "flutter run" on Androidteam-androidOwned by Android platform teamtoolAffects the "flutter" command-line tool. See also t: labels.triaged-androidTriaged by Android platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions