React-native-code-push: release-react fails for Android app with dynamic build.gradle

Created on 31 Jan 2018  路  1Comment  路  Source: microsoft/react-native-code-push

Steps to Reproduce

  1. Have the following section in android/app/build.gradle (other config removed for clarity):
def getVersionName = { ->
    return project.hasProperty('versionName') ? versionName : "0.0.1"
}

android {
  defaultConfig {
    versionName getVersionName()
  }
}

  1. Run React Native app as normal (this works fine)
react-native run-android
  1. Create a codepush release:
appcenter codepush release-react -a <app_name>

Expected Behavior

The release is created.

Actual Behavior

The release fails with error:

Detecting android app version:

Error: Command 'codepush release-react -a will.morton-1/Scoot-Android' failed with exception "No property named "getVersionName()" exists in the "android/gradle.properties" file."

Changing the versionName to a static string removes the error, so the issue appears to be that the bundler is not interpreting the file as gradle but rather grepping for the value - this is at odds with the react-native build system itself.

This error suggests that codepush will not support any dynamic methods within a build.gradle file, which is a fairly major limitation.

Environment

  • react-native-code-push version: 5.2.1
  • react-native version: 0.52.1

Most helpful comment

Hi @willmortonscoot

Unfortunately we can't execute getVersionName() but CLI require version.
To avoid this error you should use -t|--target-binary-version option:

appcenter codepush release-react -a <app_name> -t <version>

Thanks!

>All comments

Hi @willmortonscoot

Unfortunately we can't execute getVersionName() but CLI require version.
To avoid this error you should use -t|--target-binary-version option:

appcenter codepush release-react -a <app_name> -t <version>

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

panarasi picture panarasi  路  4Comments

Adr1ann picture Adr1ann  路  3Comments

fanzhiri picture fanzhiri  路  3Comments

sergey-akhalkov picture sergey-akhalkov  路  4Comments

ACCTFORGH picture ACCTFORGH  路  3Comments