【问题标题】:react-native, "abortOnError false" and yet the android build fails due to lint errorreact-native,“abortOnError false”,但由于 lint 错误,android 构建失败
【发布时间】:2021-02-12 00:48:36
【问题描述】:

在我的 react-native 应用程序中,为 android 构建我得到 lint 错误失败。我想忽略它,但添加推荐的脚本并不能解决问题,而且构建仍然失败

./gradlew build

* What went wrong:
Execution failed for task ':react-native-maps: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
      }
  }
  ...

并已将推荐添加到app/build.gradle

android {
    compileSdkVersion rootProject.ext.compileSdkVersion
    compileOptions {...}
    defaultConfig {...}
    splits {...}
    signingConfigs {...}
    buildTypes {...}
    packagingOptions {...}

    lintOptions {
          abortOnError false
      }
}

【问题讨论】:

  • 这些设置不会影响第三方项目

标签: android react-native build.gradle gradlew react-native-maps


【解决方案1】:

你应该修改 android/build.gradle 而不是 android/app/build.gradle 因为react-native-maps 是第三方项目。

allprojects {
    // append here
    afterEvaluate {
        if (getPlugins().hasPlugin('android') ||
            getPlugins().hasPlugin('android-library')) {
            configure(android.lintOptions) {
                abortOnError false
                checkReleaseBuilds false
            }
        }
    }
}

然后运行 ​​./gradlew clean 以在另一个构建之前配置每个项目。

【讨论】:

    猜你喜欢
    • 2019-07-24
    • 1970-01-01
    • 1970-01-01
    • 2021-01-23
    • 1970-01-01
    • 2018-03-08
    • 2019-03-21
    • 1970-01-01
    • 2022-10-24
    相关资源
    最近更新 更多