react-native - React Native 在发布模式下崩溃
问题描述
当我运行react-native run-android --variant=release
它时,它在模拟器和手机上不断崩溃,没有任何错误。
我尝试了本文中的建议,但是当我运行./gradlew clean && ./gradlew assembleRelease
它时会出现此错误:
> Task :react-native-navigation:verifyReleaseResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':react-native-navigation:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
/Users/balwindersingh/Desktop/WEBSITETOON/teamwallpaper/node_modules/react-native-navigation/android/app/build/intermediates/res/merged/release/values-v28/values-v28.xml:7: error: resource android:attr/dialogCornerRadius not found.
/Users/balwindersingh/Desktop/WEBSITETOON/teamwallpaper/node_modules/react-native-navigation/android/app/build/intermediates/res/merged/release/values-v28/values-v28.xml:11: error: resource android:attr/dialogCornerRadius not found.
/Users/balwindersingh/Desktop/WEBSITETOON/teamwallpaper/node_modules/react-native-navigation/android/app/build/intermediates/res/merged/release/values/values.xml:3083: error: resource android:attr/fontVariationSettings not found.
/Users/balwindersingh/Desktop/WEBSITETOON/teamwallpaper/node_modules/react-native-navigation/android/app/build/intermediates/res/merged/release/values/values.xml:3084: error: resource android:attr/ttcIndex not found.
error: failed linking references.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 59s
180 actionable tasks: 168 executed, 12 up-to-date
解决方案
问题可能是您正在使用 sdkVersion 28 构建您的应用程序,而 react-navigation 使用的是旧版本。
您可以覆盖android/build.gradle
文件中的版本:
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion compileSdkVersion
buildToolsVersion "$buildToolsVersion"
}
}
}
}
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 27
supportLibVersion = "28.0.0"
}
(我不确定这是否是最好的方法......)
或者,您可以分叉 react-navigation 并将其android/app/build.gradle
文件中的版本更改为28
.
推荐阅读
- bash - sed 或 awk 将内容添加到在 git bash v2.21.0 中运行的 ac 函数体
- azure - Azure 专用终结点上的 HTTP 与 HTTPS 通信
- javascript - Divi 中的 CSS - 单击简介时触发手风琴/切换开关
- c - 使用 FreeType C 绘制 8pt 字母的线应该多高
- python - 仅替换确切的字符串
- java - 错误 - 将一个服务的依赖项注入另一个服务控制器时,一个“包”类型的 bean [Spring-Boot]
- vue.js - 如何将 d3-grap-gallery 实现到 Vuejs
- c# - 从 file.io 下载文件“X-Cache:来自云端的 LambdaExecutionError”“服务暂时不可用”
- socket.io - 如何修改正在进行的连接上的流以暂停/恢复流传输
- python - word-embendding:将监督模型转换为无监督模型