在Facebook SDK安装时生成错误

时间:2018-09-17 09:07:38

标签: android android-studio react-native build.gradle facebook-sdk-4.x

我正在尝试将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

有人可以启发我吗?

3 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:1)

原来,我不得不更新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

谢谢大家的回答和时间!

答案 2 :(得分:0)

cd android
gradlew clean

然后删除node_modules文件夹

npm install

再次重建它应该可以修复错误