microsoft / react-native-code-push

React Native module for CodePush
http://appcenter.ms
Other
8.99k stars 1.48k forks source link

No property named env.get(VERSION_NAME) exists in the android/gradle.properties file #2159

Closed dentep closed 2 years ago

dentep commented 3 years ago

I have built an app that collects the env props in React Native, but codepush is unable to read the version name from those files.

Steps to Reproduce

  1. Create .env file with VERSION_NAME param in it
  2. Read it from app/build.gradle (versionName project.env.get("VERSION_NAME"))
  3. Build and run your app
  4. Try to codepush the app

Expected Behavior

Command runs without errors and finishes the codepush process

Actual Behavior

Command throws an error: "No property named env.get(VERSION_NAME) exists in the android/gradle.properties file".

Environment

ghost commented 2 years ago

This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs within 15 days of this comment.

ghost commented 2 years ago

This issue will now be closed because it hasn't had any activity for 15 days after stale. Please feel free to open a new issue if you still have a question/issue or suggestion.

imran-hossain03 commented 2 years ago

Getting the same error

anhquan291 commented 2 years ago

I'm also facing the same issue. Any updates please? Thanks a lot

levi218 commented 2 years ago

I think you should export the VERSION_NAME variable manually before running codepush, or running this command to load the .env file into the console

export $(grep -v '^#' .env | xargs)
vagnerlandio commented 1 year ago

I was gettings the same error with the following files and settings:

# android/gradle.properties
versionName=1.23.5
# android/app/build.gradle
android {
    ...
    defaultConfig {
        ...
        versionCode project.getProperties().get("versionCode").toInteger()
        versionName project.getProperties().get("versionName")
    }
    ...
}

To solve the issue, I just made the following change in the build.gradle file:

# android/app/build.gradle
android {
    ...
    defaultConfig {
        ...
        versionCode project.getProperties().get("versionCode").toInteger()
-       versionName project.getProperties().get("versionName")
+       versionName project.versionName
    }
    ...
}