Skip to content

Split ABI build version code is no longer range separated #169790

@v0l

Description

@v0l

Steps to reproduce

  1. Building APK with flutter 2.29 & --split-per-abi with version code 12 should produce versioncode 2012 etc
  2. All APK builds currently built in 3.32 have versionCode 12

Expected results

Version codes should match as per google docs https://developer.android.com/build/configure-apk-splits#configure-APK-versions

Actual results

All version codes are the same for armeabi-v7a arm64-v8a x86_64

Code sample

Code sample

build.gradle.kts

import com.android.build.api.dsl.ApkSigningConfig
import org.jetbrains.kotlin.gradle.targets.js.toHex
import java.io.FileInputStream
import java.util.Base64
import java.security.MessageDigest
import java.util.Properties

plugins {
    id("com.android.application")
    id("kotlin-android")
    id("dev.flutter.flutter-gradle-plugin")
    id("com.google.gms.google-services")
}

fun getKeystoreFile(base64String: String?, hash: String, fileName: String): File {
    if (base64String == null) {
        throw GradleException("Keystore is null")
    }
    val decodedBytes = Base64.getDecoder().decode(base64String)
    val tempFile = File("${layout.buildDirectory.get()}/keystores/${fileName}")
    tempFile.parentFile.mkdirs()
    tempFile.writeBytes(decodedBytes)

    val digest = MessageDigest.getInstance("SHA-256")
    val tmpHash = digest.digest(decodedBytes)
    if (tmpHash.toHex() != hash) {
        throw GradleException("Keystore hash mismatch")
    }
    return tempFile
}

val keystorePropertiesFile = rootProject.file("key.properties")
val keystoreProperties = if (keystorePropertiesFile.exists()) {
    Properties().apply {
        load(FileInputStream(keystorePropertiesFile))
    }
} else {
    Properties()
}

android {
    signingConfigs {
        create("keyFile") {
            keyAlias = keystoreProperties.getProperty("keyAlias")
            keyPassword = keystoreProperties.getProperty("keyPassword")
            storeFile =
                keystoreProperties.getProperty("storeFile")?.let {
                    file(it)
                }
            storePassword = keystoreProperties.getProperty("storePassword")
        }
    }
}

fun getSigningConfig(): ApkSigningConfig {
    if (!System.getenv("KEYSTORE").isNullOrEmpty()) {
        println("Signing: using env vars")
        val cfg = android.signingConfigs.create("env") {
            keyAlias = System.getenv("KEY_ALIAS")
            keyPassword = System.getenv("KEY_PASSWORD")
            storeFile = System.getenv("KEYSTORE")?.let {
                getKeystoreFile(
                    it,
                    System.getenv("KEYSTORE_SHA256"),
                    "store.jks"
                )
            }
            storePassword = System.getenv("KEYSTORE_PASSWORD")
        }
        return cfg
    }
    println("Signing: using key.properties")
    return android.signingConfigs.getByName("keyFile")
}

// pick signing config
val cfg = getSigningConfig()

android {
    namespace = "io.nostrlabs.zap_stream_flutter"
    compileSdk = flutter.compileSdkVersion
    ndkVersion = flutter.ndkVersion

    compileOptions {
        isCoreLibraryDesugaringEnabled = true
        sourceCompatibility = JavaVersion.VERSION_11
        targetCompatibility = JavaVersion.VERSION_11
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_11.toString()
    }

    defaultConfig {
        applicationId = "io.nostrlabs.zap_stream_flutter"
        minSdk = flutter.minSdkVersion
        targetSdk = flutter.targetSdkVersion
        versionCode = flutter.versionCode
        versionName = flutter.versionName
    }

    buildTypes {
        release {
            signingConfig = cfg
        }
    }
}

flutter {
    source = "../.."
}

dependencies {
    coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:2.1.4")
}

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.32.1, on Ubuntu 24.04.2 LTS 6.11.0-26-generic, locale en_US.UTF-8) [97ms]
    • Flutter version 3.32.1 on channel stable at /home/kieran/git/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b25305a883 (28 hours ago), 2025-05-29 10:40:06 -0700
    • Engine revision 1425e5e9ec
    • Dart version 3.8.1
    • DevTools version 2.45.1

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.1) [4.6s]
    • Android SDK at /home/kieran/Android/Sdk/
    • Platform android-35, build-tools 35.0.1
    • Java binary at: /home/kieran/Downloads/android-studio/jbr/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at google-chrome) [16ms]
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✓] Linux toolchain - develop for Linux desktop [375ms]
    • Ubuntu clang version 18.1.3 (1ubuntu1)
    • cmake version 3.28.3
    • ninja version 1.11.1
    • pkg-config version 1.8.1
    • OpenGL core renderer: NV193 (X11)
    • OpenGL core version: 4.3 (Core Profile) Mesa 24.2.8-1ubuntu1~24.04.1 (X11)
    • OpenGL core shading language version: 4.30 (X11)
    • OpenGL ES renderer: NV193 (X11)
    • OpenGL ES version: OpenGL ES 3.2 Mesa 24.2.8-1ubuntu1~24.04.1 (X11)
    • OpenGL ES shading language version: OpenGL ES GLSL ES 3.20 (X11)
    • GL_EXT_framebuffer_blit: yes (X11)
    • GL_EXT_texture_format_BGRA8888: yes (X11)

[✓] Android Studio (version 2024.3.2) [12ms]
    • Android Studio at /home/kieran/Downloads/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13368085-b895.109)

[✓] VS Code (version unknown) [10ms]
    • VS Code at /snap/code/current/usr/share/code
    • Flutter extension version 3.110.0
    ✗ Unable to determine VS Code version.

[✓] Connected device (1 available) [44ms]
    • Linux (desktop) • linux • linux-x64 • Ubuntu 24.04.2 LTS 6.11.0-26-generic

[✓] Network resources [560ms]
    • All expected network resources are available.

! Doctor found issues in 1 category.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfyi-toolFor the attention of Flutter Tool teamplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-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