3

I use the MS CodePush to push react native code, but the log shows:

 [CodePush] 400: An update check must include a deployment key, and provide a semver compliant app version.

I have supplied the deployment key in Activity:

@Override
protected List<ReactPackage> getPackages() {
    // 4. Instantiate an instance of the CodePush runtime, using the right deployment key
    codePush = new CodePush("g-*********", this, BuildConfig.DEBUG);//staging

    return Arrays.<ReactPackage>asList(
                    new MainReactPackage(), codePush.getReactPackage(), new RNPackage());
}

And set versionName in build.gradle:

android {
    useLibrary  'org.apache.http.legacy'

    compileSdkVersion COMPILE_SDK_VERSION as int
    buildToolsVersion BUILD_TOOLS_VERSION

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 22

        versionName "2.1.5"
        versionCode 35
        applicationId "com.xx"
        // Enabling multidex support.
        multiDexEnabled true

        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
buildTypes {
    debug {
        buildConfigField "boolean", "PRINT_LOG", "true"
        buildConfigField "String", "SERVER_TYPE", '"dev"'
        #versionNameSuffix "_debug"  #[SOLVED]Here is the error goes! remove this line and it works!
        signingConfig signingConfigs.release
    }

and in JS:

 componentDidMount() {

//    codePush.sync();
    codePush.sync({ deploymentKey: "g-******************" });

  }
herbertD
  • 10,657
  • 13
  • 50
  • 77
  • Thanks! Joachim Isaksson – herbertD Feb 23 '16 at 07:00
  • 1
    Could you try logging `getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionName`? What value do you see? – Geoffrey Goh Feb 23 '16 at 19:34
  • Thanks for the reply, The version name is : 2.1.5_debug – herbertD Feb 25 '16 at 01:54
  • 1
    "2.1.5_debug" is not a valid semver string, our server expects a valid semver such as "2.1.5". I see in your Gradle file that you have defined it as just "2.1.5", where does the "_debug" come from? Did you define it elsewhere e.g. in the "AndroidManifest.xml" file? – Geoffrey Goh Feb 25 '16 at 02:38
  • I set the version to 2.1.5 and it works! Thanks, Geoffrey, I own you a cup of coffee. – herbertD Feb 25 '16 at 03:16
  • please answer this question below and I will accept it. – herbertD Feb 25 '16 at 03:17
  • 1
    No probs! Thanks for using CodePush!! Feel free to ping me whenever you have questions, and raise issues on GitHub if you find that something is not working for you! – Geoffrey Goh Feb 25 '16 at 09:33
  • @GeoffreyGoh is this error harmful other than creating a little noise in the log? Is it OK if I intentionally set my version to an invalid semver to keep codepush out of my way while developing? I don't want it to apply an old update to my new stuff. – chetstone Apr 23 '16 at 16:55
  • @chetstone Well, yes. You could also do wrap the call to `codePush.sync()` in `if (!__DEV__) { ... }` to make sure it only syncs up during production – Geoffrey Goh Apr 24 '16 at 07:27

1 Answers1

2

"2.1.5_debug" is not a valid semver string, our server expects a valid semver such as "2.1.5".

I see in your Gradle file that you have defined it as just "2.1.5", where does the "_debug" come from? Did you define it elsewhere e.g. in the "AndroidManifest.xml" file?

Geoffrey Goh
  • 233
  • 1
  • 7