React-Native:gradlew 构建产生:react-native-fbsdk:lint 错误 "libraries must use the exact same version"

React-Native: gradlew build yields :react-native-fbsdk:lint error "libraries must use the exact same version"

我是 运行 ./gradlew build 添加 facebook-android-sdk 后出现以下错误。这在 Windows 和 Mac 上都有,Gradle 4.10.1.

> Task :react-native-fbsdk:lint
Ran lint on variant debug: 19 issues found
Ran lint on variant release: 19 issues found
Wrote HTML report to file:///C:/Foo/Bar/src/ReactNative/node_modules/react-native-fbsdk/android/build/reports/lint-results.html
Wrote XML report to file:///C:/Foo/Bar/src/ReactNative/node_modules/react-native-fbsdk/android/build/reports/lint-results.xml

> Task :react-native-fbsdk:lint FAILED

FAILURE: Build failed with an exception.

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

  C:\Foo\Bar\src\ReactNative\node_modules\react-native-fbsdk\android\build.gradle: Error: All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 27.0.2. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:cardview-v7:27.0.2 [GradleCompatible]

具体来说,com.android.support:animated-vector-drawable:28.0.0com.android.support:cardview-v7:27.0.2 之间存在兼容性问题。其他人通过更改 build.gradle

中的这一行解决了类似问题
implementation 'com.facebook.android:facebook-android-sdk:[4,5)'

...像这样:

implementation('com.facebook.android:facebook-android-sdk:[4,5)') {
    exclude group: 'com.android.support', module: 'support-v4'
    exclude group: 'com.android.support', module: 'appcompat-v7'
    exclude group: 'com.android.support', module: 'cardview-v7'
    exclude group: 'com.android.support', module: 'customtabs'
    exclude group: 'com.android.support', module: 'support-annotations'
    exclude group: 'com.android.support', module: 'support-core-utils'
    exclude group: 'com.android.support', module: ':animated-vector-drawable'
}

implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:customtabs:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

当我查看依赖项时,它们似乎已正确解析为 28.0.0, 不是错误中指示的 27.0.2:

./gradlew -q dependencies app:dependencies --configuration debugAndroidTestCompileClasspath
=> 
// ...
+--- com.facebook.android:facebook-android-sdk:4.40.0
|    +--- com.facebook.android:facebook-core:4.40.0
|    |    +--- com.parse.bolts:bolts-android:1.4.0
|    |    |    +--- com.parse.bolts:bolts-tasks:1.4.0
|    |    |    \--- com.parse.bolts:bolts-applinks:1.4.0
|    |    |         \--- com.parse.bolts:bolts-tasks:1.4.0
|    |    +--- com.android.support:support-annotations:27.0.2 -> 28.0.0
|    |    \--- com.android.support:support-core-utils:27.0.2 -> 28.0.0 (*)
|    +--- com.facebook.android:facebook-common:4.40.0
|    |    +--- com.facebook.android:facebook-core:4.40.0 (*)
|    |    +--- com.android.support:support-v4:27.0.2 -> 28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:support-media-compat:28.0.0
|    |    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    |    \--- com.android.support:versionedparcelable:28.0.0 (*)
|    |    |    +--- com.android.support:support-core-utils:28.0.0 (*)
|    |    |    +--- com.android.support:support-core-ui:28.0.0 (*)
|    |    |    \--- com.android.support:support-fragment:28.0.0 (*)
|    |    +--- com.android.support:appcompat-v7:27.0.2 -> 28.0.0 (*)
|    |    +--- com.android.support:cardview-v7:27.0.2 -> 28.0.0
|    |    |    \--- com.android.support:support-annotations:28.0.0
|    |    +--- com.android.support:customtabs:27.0.2 -> 28.0.0
|    |    |    +--- com.android.support:support-compat:28.0.0 (*)
|    |    |    +--- com.android.support:support-annotations:28.0.0
|    |    |    +--- com.android.support:interpolator:28.0.0 (*)
|    |    |    +--- com.android.support:collections:28.0.0 (*)
|    |    |    \--- com.android.support:support-core-ui:28.0.0 (*)
|    |    \--- com.google.zxing:core:3.3.0

知道这里发生了什么吗?

编辑 其他不起作用的东西:

如果我将它放在 app/build.gradle:

中,这似乎会禁用 lint 中的错误
allprojects {
    // ...
    afterEvaluate {
        if (getPlugins().hasPlugin('android') ||
            getPlugins().hasPlugin('android-library')) {

            println name // for debugging

            configure(android.lintOptions) {
                 abortOnError false
            }
        }
     }
}

来源:How to disable lint abortOnError in Android Gradle Plugin from top level of multi project directory