在facebook sdk安装时构建错误

问题描述 投票:0回答:3

我正在尝试将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 android-studio react-native build.gradle facebook-sdk-4.x
3个回答
1
投票

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

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

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

谢谢大家的答案和时间!


0
投票
cd android
gradlew clean

然后删除node_modules文件夹

npm install

再次重建它应该修复错误

© www.soinside.com 2019 - 2024. All rights reserved.