我使用 MS CodePush 推送反应原生代码,但日志显示:
[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-******************" });
}