在发布模式下React Native崩溃

时间:2019-06-05 17:41:58

标签: react-native

当我运行react-native run-android --variant=release时,它连续崩溃,模拟器和手机上都没有任何错误。

我尝试了this article中的建议,但是当我运行./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

3 个答案:

答案 0 :(得分:0)

问题可能是您使用sdkVersion 28构建应用程序,而反应导航使用的是旧版本。

您可以覆盖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

答案 1 :(得分:0)

请勿删除res文件夹中的可绘制文件夹。如果您遵循该文章,则删除导致错误的那些可绘制文件夹。尝试不删除可绘制文件夹。

答案 2 :(得分:0)

就我而言,我在应用程序中留下了console.log()语句,因此它在调试模式下运行完全正常,但在发布模式下崩溃了。在深入研究之后,我意识到这是一个小问题。 因此,也请检查您的应用页面是否存在此类小问题。