0

I'm trying to automate publishing an app to the Google Play store using the Gradle Play Publisher. So far so good except that I haven't been able to update the version_name this way, it just ignores it.

I Tried ./gradlew publishRelease -Dversion_name=3.0.0. It looks like it's due to Google Play API limitations. If I run ./gradlew assembleRelease -Dversion_name=3.0.0 to generate the apk and then upload the apk manually it correctly uploads with the version 3.0.0. Just want to make sure is it not possible to upload the version name vía Google Play Developer API or is it an issue of Gradle Play Publisher?

build.gradle

def version_name = System.getProperty("version_name")

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        versionCode version_code
        versionName "${version_name}"
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
        multiDexEnabled true

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
}

EDIT:

Following R. Zagórski suggestions I tried:

1.

./gradlew assembleRelease -Dversion_name=3.0.0 publishRelease

and

2.

./gradlew assembleRelease -Pversion_name=3.0.0 publishRelease

build.gradle

def version_name = project.getProperty("version_name")
println "version name: "+version_name

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 23
        versionCode version_code
        versionName "${version_name}"
        renderscriptTargetApi 23
        renderscriptSupportModeEnabled true
        multiDexEnabled true

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    ...
}

But still nothing. Just to be clear the problem is not that I'm not getting the version_name or the wrong version_name in the build, in fact that println you see there prints the right version. Is just that I'm not getting anything at all in the Google play store (see image below).

enter image description here

Mauricio
  • 839
  • 2
  • 13
  • 26

1 Answers1

0

This is not the issue of plugin or API. This is just how gradle works. Other answers indicating the problem are here or here.

Basically the problem is that gradle might create a JVM fork processes to complete the tasks. Therefore, when running publishRelease, which depends on assembleRelease, separate process might be created to finish assembling before publishing. And you pass system property to publish taksand not assemble task.

The solution might be to run two tasks simultaneously, passing argument to appropriate one:

./gradlew assembleRelease -Dversion_name=3.0.0 publishRelease

Or set project property instead of system property as described here

Community
  • 1
  • 1
R. Zagórski
  • 20,020
  • 5
  • 65
  • 90