0

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?

Kostis
  • 953
  • 9
  • 21
  • https://github.com/react-native-community/react-native-camera/issues/1532 and https://github.com/flutter/flutter/issues/14020 – IntelliJ Amiya Sep 17 '18 at 09:09

3 Answers3

1

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
            }
        }
    }
}
LordKiz
  • 603
  • 6
  • 15
  • Added to the bottom of the file but still no luck. – Kostis Sep 17 '18 at 11:26
  • I once had a problem with FBSDK similar to yours. Try this: in your `.android/app/build.gradle` just below `dependencies` add this: `configurations.all { resolutionStrategy { force 'com.facebook.android:facebook-android-sdk:4.22.1' //or your preferred } }` – LordKiz Sep 17 '18 at 11:33
  • just to add, if you are on mac also run `cd android` then `./gradlew clean` after you edit the gradle files. If on windows just cd to android and run `gradlew clean` – LordKiz Sep 17 '18 at 11:39
  • LordKiz, thank you very much for your answers. I tried everything but still no success. Whatever I do, I still get the same error. What does this error mean? In what version should I switch and what is DependencyResolution? – Kostis Sep 17 '18 at 13:06
  • It just says there are conflicting build dependencies. Have you used my answer and specified the main build tools you are using within your app? – LordKiz Sep 17 '18 at 13:35
1

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!

Kostis
  • 953
  • 9
  • 21
0
cd android
gradlew clean

Delete node_modules folder then

npm install

Rebuild again an it should fix the error

  • Tried with gradle instead of gradlew because the latter could not be found, reinstalled all packages but still no luck. – Kostis Sep 17 '18 at 11:27