react-native,“ abortOnError false”,但由于lint错误导致Android构建失败

时间:2020-10-29 14:45:32

标签: android react-native build.gradle gradlew 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
      }
  }
  ...

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

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

    lintOptions {
          abortOnError false
      }
}

1 个答案:

答案 0 :(得分:0)

由于react-native-maps是第三方项目,因此您应修改 android / build.gradle 而不是 android / app / build.gradle

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

然后运行./gradlew clean来配置每个项目,然后再进行另一个构建。