Set android app version from command line

Viewed 195

I'm trying to set android app version code and name using project variables on running:

./gradlew bundleRelease -PversionName=1.0.0 -PversionCode=100

To use this on my app/build.gradle file:

defaultConfig {
    versionCode project.versionCode
    versionName project.versionName
    [...]
}

I remember to use this once, but this time I'm receiving the following weird error:

A problem occurred evaluating project ':app'.
> No signature of method: build_3d8oq36p9lc2a0ylsa4yduj2n.android() is applicable for argument types: (build_3d8oq36p9lc2a0ylsa4yduj2n$_run_closure1) values: [build_3d8oq36p9lc2a0ylsa4yduj2n$_run_closure1@6e40553b]

How can I set the app version code and name with gradle on the command line?

1 Answers

Thanks, @akif for the help!

defaultConfig {
    versionCode project.versionCode.toInteger()
    versionName project.versionName
    [...]
}
Related