Build error upon facebook sdk installation

380 Views Asked by At

I am trying to install Facebook SDK to my react-native app which is being installed successfully, but when I try to run the app, it crashes with the following error:

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

This error originates from another installed sdk (jumio) and more specifically from the file application/node_modules/react-native-jumio-mobilesdk/android/build.gradle

Can someone please enlighten me?

3

There are 3 best solutions below

1
On

Turns out I had to update all the dependencies of com.android.support and not only the com.android.support:v4:xx.x.x. In my case it was

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

Thank you all for your answers and your time!

5
On

When you have configurations clashing, you can force all projects to use a single build config Add this to bottom of your ./android/build.gradle

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

Delete node_modules folder then

npm install

Rebuild again an it should fix the error