【问题标题】:Code push return 400 error代码推送返回400错误
【发布时间】:2016-02-23 06:36:02
【问题描述】:

我使用MS CodePush推送react native代码,但是日志显示:

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

我在 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());
}

并在 build.gradle 中设置 versionName:

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
    }

在 JS 中:

 componentDidMount() {

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

  }

【问题讨论】:

  • 谢谢!约阿希姆·伊萨克森
  • 您可以尝试记录getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionName 吗?你看到了什么价值?
  • 感谢回复,版本名称为:2.1.5_debug
  • "2.1.5_debug" 不是有效的 semver 字符串,我们的服务器需要一个有效的 semver,例如 "2.1.5"。我在您的 Gradle 文件中看到您已将其定义为“2.1.5”,“_debug”来自哪里?您是否在其他地方定义了它,例如在“AndroidManifest.xml”文件中?
  • 没有问题!感谢您使用 CodePush!如果您有任何问题,请随时联系我,如果您发现某些内容不适合您,请在 GitHub 上提出问题!

标签: javascript android react-native code-push


【解决方案1】:

“2.1.5_debug”不是有效的 semver 字符串,我们的服务器需要一个有效的 semver,例如“2.1.5”。

我在您的 Gradle 文件中看到您已将其定义为“2.1.5”,“_debug”来自哪里?您是否在其他地方定义了它,例如在“AndroidManifest.xml”文件中?

【讨论】:

    猜你喜欢
    • 2016-03-16
    • 2012-11-08
    • 1970-01-01
    • 2015-03-15
    • 2019-07-12
    • 2019-11-14
    • 1970-01-01
    • 2018-12-16
    • 2020-09-06
    相关资源
    最近更新 更多