首页 > 解决方案 > ./gradlew clean build 上的 RNC Slider lint 失败,并在应用启动时发布 apk 崩溃

问题描述

在组装发布之前,我正在尝试进行干净的构建,但它会引发错误并使任务失败。当我生成发布 apk(成功生成)后,在我的 LG G4 手机(也尝试过三星 Galaxy J3)上安装它后,它崩溃并且无法启动。

react-native run-android我的应用程序在我的手机上成功运行。

在组装发布版本之前,我输入了

cd android
./gradlew clean
./gradlew buildcache
./gradlew clean build

最后一个命令总是给出错误。

添加后

  android {
      lintOptions {
          abortOnError false
      }
  }

正如错误所说,到 RNC Slider 的 build.gradle 文件,./gradlew clean build成功完成其任务。但是在生成和安装发布 apk 后我仍然无法打开应用程序。

./gradlew clean build错误:

...
> Task :@react-native-community_slider:lint FAILED
Ran lint on variant release: 3 issues found
Ran lint on variant debug: 3 issues found
Wrote HTML report to file:///D:/React/Pure%20RN/dassist/node_modules/@react-native-community/slider/android/build/reports/lint-results.html
Wrote XML report to file:///D:/React/Pure%20RN/dassist/node_modules/@react-native-community/slider/android/build/reports/lint-results.xml

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':@react-native-community_slider:lint'.
> Lint found errors in the project; aborting build.

  Fix the issues identified by lint, or add the following to your build script to proceed with errors:
  ...
  android {
      lintOptions {
          abortOnError false
      }
  }
  ...

  Errors found:

  D:\React\Pure RN\dassist\node_modules\@react-native-community\slider\android\src\main\java\com\reactnativecommunity\slider\ReactSliderManager.java:68: Error: Value must be ? 0 (was -2) [Range]
              ViewGroup.LayoutParams.WRAP_CONTENT,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



* 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

BU¦LD FAILED in 35s
163 actionable tasks: 154 executed, 9 up-to-date

这是输出日志中提到的 xml 报告文件(不包括警告)的一部分:

<issues format="5" by="lint 3.3.1">

    <issue
        id="Range"
        severity="Error"
        message="Value must be ≥ 0 (was -2)"
        category="Correctness"
        priority="6"
        summary="Outside Range"
        explanation="Some parameters are required to in a particular numerical range; this check makes sure that arguments passed fall within the range. For arrays, Strings and collections this refers to the size or length."
        errorLine1="            ViewGroup.LayoutParams.WRAP_CONTENT,"
        errorLine2="            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~">
        <location
            file="D:\React\Pure RN\dassist\node_modules\@react-native-community\slider\android\src\main\java\com\reactnativecommunity\slider\ReactSliderManager.java"
            line="68"
            column="13"/>
    </issue>

</issues>

标签: react-nativeandroid-gradle-plugin

解决方案


推荐阅读