react-native,“abortOnError false”,但 android 构建由于 lint 错误而失败

Ami*_*avi 3 android gradlew build.gradle react-native react-native-maps

在我的 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
      }
  }
  ...
Run Code Online (Sandbox Code Playgroud)

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

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

    lintOptions {
          abortOnError false
      }
}
Run Code Online (Sandbox Code Playgroud)

Sea*_* C. 7

您应该修改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
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

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