Tas-6ren">
gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 05:03:45 29 4
gpt4 key购买 nike

我在添加 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:\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

知道这里发生了什么吗?

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

  • 按照错误消息中的建议将 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 中,这似乎会禁用 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

关于android - React-Native: gradlew build yields:react-native-fbsdk:lint 错误 "libraries must use the exact same version",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54950511/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com