Facebook SDK 安装时出现构建错误



我正在尝试将Facebook SDK安装到已成功安装的 react-native 应用程序中,但是当我尝试运行该应用程序时,它崩溃并显示以下错误:

Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:support-v4' has different version for the compile (27.0.2) and runtime (27.1.1) classpath. You should manually set the same version via DependencyResolution

此错误源自另一个已安装的 sdk (jumio(,更具体地说来自文件application/node_modules/react-native-jumio-mobilesdk/android/build.gradle

有人可以开导我吗?

当配置发生冲突时,可以强制所有项目使用单个构建配置 将其添加到./android/build.gradle底部

subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 26 //or your preferred
buildToolsVersion "26.0.3" // your preferred
}
}
}
}

事实证明,我必须更新com.android.support的所有依赖项,而不仅仅是com.android.support:v4:xx.x.x。就我而言,它是

implementation com.android.support:support-v4:27.0.2
api com.android.support:appcompat-v7:27.0.2
implementation com.android.support:design:27.0.2
implementation com.android.support:cardview-v7:27.0.2

谢谢大家的回答和时间!

cd android
gradlew clean

然后删除node_modules文件夹

npm install

再次重建,它应该修复错误

最新更新