'Firebase app distribution via gradle updating the same APK instead of creating new one

I recently integrated firebase app distribution in my app and used the Firebase console. I used to generate APK and upload manualy via console and distribute the app. I was so naive. Then I came to know that this entire process can be automated via Fastlane or Gradle app distribution. support. I was successful in integrating the app distribution via gradle thanks to this.

But I soon observed that when I was using the console a new entry was created for every new APK no matter the version name or version code ie. new APK entry was created even if I did not change the APK version code or name. However, when I am doing it through Gradle it is updating the same APK again and again until I change the version code and name.

Already gone through the documentation but there is no mention of this. Do i need to change the version code and name for every upload if i want a new entry for it in the app distribution console?

build.gradle(app)

buildTypes {
     debug{
         firebaseAppDistribution {
             appId = "MY_APP_ID"
             releaseNotesFile = "app/releasenotes.txt"
             groups = "test"
         }
     }

to upload i run ./gradlew assembleDebug appDistributionUploadDebug



Solution 1:[1]

I faced the same problem while trying to push feature-branch builds, i wanted to not have any different version code

I did some try and error to fix the problem so my solution is kind of out of the box.

Solution 1

First I tried to see what was the issue, and I have added a groovy method that generates a timestamp

static def getDate() {
    return new Date().format('yyyyMMddHHmm')
}

then i have changed the buildType.debug.versionNameSuffix to have a name for each build based on the timestamp, so we got this

versionNameSuffix "-DEBUG-" + getDate()

enter image description here

Solution 2

As our Github Action CI doesn't need to name the name of the debug apk file, why don't just change that file name?

So the gradle change becomes

defaultConfig {
    archivesBaseName = "${applicationId}-v${versionName}(${versionCode})" + getDate()
}

And we get this output

enter image description here

I hope this will help you

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 gmetax