Search code examples
javascriptandroidreact-nativecode-push

Code push return 400 error


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-******************" });

  }

Solution

  • "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?