#android #react-native #react-native-android #visual-studio-app-center #react-native-code-push
#Android #react-native #visual-studio-app-center #react-native-code-push
Вопрос:
не уверен, в чем проблема. при сборке / распространении в Microsoft appcenter проблем не возникало. единственное, что я помню, что делал с code-push после его успешной сборки, — это добавлял разные ключи развертывания в build.gradle:
buildTypes {
debug {
signingConfig signingConfigs.debug
// Note: CodePush updates should not be tested in Debug mode as they are overriden by the RN packager. However, because CodePush checks for updates in all modes, we must supply a key.
// specifically left blank in appcenter docs
resValue "string", "CodePushDeploymentKey", '""'
}
releaseStaging {
resValue "string", "CodePushDeploymentKey", '"<key>"'
// Note: It is a good idea to provide matchingFallbacks for the new buildType you create to prevent build issues
// Add the following line if not already there
matchingFallbacks = ['release']
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
// signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
resValue "string", "CodePushDeploymentKey", '"<key>"'
}
}
теперь, когда я пытаюсь выполнить сборку из Android studio, я получаю эту ошибку:
> Task :react-native-code-push:javaPreCompileDebug UP-TO-DATE
> Task :react-native-code-push:compileDebugJavaWithJavac FAILED
/Users/vorousjames/Desktop/Development/Slide/Slide/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java:157: error: cannot find symbol
isLiveReloadEnabled = devInternalSettings.isReloadOnJSChangeEnabled();
^
symbol: method isReloadOnJSChangeEnabled()
location: variable devInternalSettings of type DevInternalSettings
/Users/vorousjames/Desktop/Development/Slide/Slide/node_modules/react-native-code-push/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java:175: warning: [unchecked] unchecked cast
List<ReactRootView> mAttachedRootViews = (List<ReactRootView>)mAttachedRootViewsField.get(instanceManager);
^
required: List<ReactRootView>
found: Object
1 error
1 warning
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-code-push:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
Что является причиной этого и как исправить эту проблему?
Ответ №1:
-
Сохраните импорт в MainApplication.java
импортируйте com.microsoft.codepush.react.CodePush;
-
Сохраните переопределенный метод getJSBundleFile.
-
Удалите buildConfigFields и обновите до этого формата
resValue "string",
« reactNativeCodePush_androidDeploymentKey
«, '"<INSERT_PRODUCTION_KEY>"'
- Удалите ключ из
strings.xml
, если он был добавлен туда.
Следуйте инструкциям для получения всех подробностей здесь