在添加Facebook-android-SDK之后,我正在运行./gradlew build
,并且我会收到以下错误。这既是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:FooBarsrcReactNativenode_modulesreact-native-fbsdkandroidbuild.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.0
和com.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
知道这里发生了什么?
编辑其他不起作用的事情:
- 如错误消息中建议的那样,将lintoptions添加到
build.gradle
没有效果。 - 清除
$HOME/.gradle
缓存和ReactNative/android/.gradle
缓存 - 升级到Gradle 4.10.3
- 在
lintOptions
中添加disable "GradleDependency"
- 用
//noinspection GradleDependency
标记线 -
lintOptions.tasks.lint.enabled = false
如果我将其放入app/build.gradle
:
allprojects {
// ...
afterEvaluate {
if (getPlugins().hasPlugin('android') ||
getPlugins().hasPlugin('android-library')) {
println name // for debugging
configure(android.lintOptions) {
abortOnError false
}
}
}
}
来源:如何从多项目目录的顶级禁用Android Gradle插件中的lint AbortonError