React-native-config: Problem using project.env inside gradlew.build

Created on 14 May 2017  路  4Comments  路  Source: luggit/react-native-config

Hi, I have in my .env file, the following

ANDROID_BUILD_VERSION=1.9
ANDROID_BUILD_NUMBER=9

Next, in my android/app/build.gralde file, i have this

defaultConfig {
    ...
    versionCode project.env.get("ANDROID_BUILD_NUMBER")
    versionName project.env.get("ANDROID_BUILD_VERSION")
    ...
}

When I run the command ./gradlew assembleRelease inside android folder, i get this error

A problem occurred evaluating project ':app'.

Could not find method versionCode() for arguments [9] on ProductFlavor_Decorated{name=main, dimension=null, minSdkVersion=DefaultApiVersion{mApiLevel=16, mCodename='null'}, targetSdkVersion=DefaultApiVersion{mApiLevel=22, mCodename='null'}, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=xxxxxxxxxxxxxxxxxxxxx, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfig=null, mBuildConfigFields={ANDROID_BUILD_NUMBER=com.android.builder.internal.ClassFieldImpl@d1dbad12, ANDROID_BUILD_VERSION=com.android.builder.internal.ClassFieldImpl@8dab9182, BUILD_DATE=com.android.builder.internal.ClassFieldImpl@4869a652, GOOGLE_API_KEY=com.android.builder.internal.ClassFieldImpl@1c3a47f1, IOS_BUILD_NUMBER=com.android.builder.internal.ClassFieldImpl@f76bc4d5, IOS_BUILD_VERSION=com.android.builder.internal.ClassFieldImpl@1a62a1c9}, mResValues={ANDROID_BUILD_NUMBER=com.android.builder.internal.ClassFieldImpl@5b09d0f2, ANDROID_BUILD_VERSION=com.android.builder.internal.ClassFieldImpl@16d9b562, BUILD_DATE=com.android.builder.internal.ClassFieldImpl@d197ca32, GOOGLE_API_KEY=com.android.builder.internal.ClassFieldImpl@a5686bd1, IOS_BUILD_NUMBER=com.android.builder.internal.ClassFieldImpl@8099e8b5, IOS_BUILD_VERSION=com.android.builder.internal.ClassFieldImpl@a390c5a9}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}, mWearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.ProductFlavor.

Thanks in advance

Most helpful comment

Hi bro,
Change your settings: versionCode project.env.get("ANDROID_BUILD_NUMBER") into

versionCode project.env.get("ANDROID_BUILD_NUMBER").toInteger()

All 4 comments

Hi bro,
Change your settings: versionCode project.env.get("ANDROID_BUILD_NUMBER") into

versionCode project.env.get("ANDROID_BUILD_NUMBER").toInteger()

Hi, could this be included in the README? 馃

:+1:! added sample to the readme

Excellent, thanks!

Was this page helpful?
0 / 5 - 0 ratings