Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native-fb sdk com.android.support dependency error

 > A problem occurred configuring project ':react-native-fbsdk'.
  > Could not resolve all dependencies for configuration ':react-native-fbsdk:_debugPublishCopy'.
     > Could not find com.android.support:appcompat-v7:27.0.1.
       Searched in the following locations:
           file:/<location_to_sdk>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.pom
           file:/<location_to_sdk>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
           file:/<location_to_app>/android/sdk-manager/com/android/support/appcompat-v7/27.0.1/appcompat-v7-27.0.1.jar
       Required by:
           newPtMobile:react-native-fbsdk:unspecified

This issue started happening this morning when running react-native run-android without making any changes to the code or adding new packages, it was working fine untill now!

"react-native":"0.50.3", "react-native-fbsdk":"0.6.3"

I can see that I am missing android support libraries in my sdk/extras/android/m2repository/com/android/support subfolders, all the subfolders have the 26.0.0-alpha1 folder as the last one. I already tried removing support repository and installing again through android studio and downloading the latest android_m2repository manually but the folders are still missing.

What I am having trouble understanding is why google's maven repository (https://dl.google.com/dl/android/maven2/index.html) states that under for example m2repository/com/android/support/appcompat-v7 I should have a folder named 27.0.2 (along with some previous versions which are also missing) but even in the latest android_m2repository which they offer it is also missing!

https://dl.google.com/android/repository/android_m2repository_r48.zip

like image 381
razbard Avatar asked Dec 06 '17 13:12

razbard


2 Answers

I also have the same issue. I was able to successfully build by updating my
ROOT : android/build.gradle file.

STEPS :
1. All you have to do is add a new maven line to the allprojects section for maven.google.com
2. Add resolutionStrategy Will Restrict your android fbsdk version to 4.28.0

allprojects {
    repositories {
        mavenLocal()
        jcenter()
        configurations.all {
        resolutionStrategy {
            force 'com.facebook.android:facebook-android-sdk:4.28.0'
        }
    }
        maven {
            url "https://maven.google.com"
        }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
      }
  }
like image 76
Syed Zain Ali Avatar answered Oct 19 '22 05:10

Syed Zain Ali


I see that another thread was open on this very same issue: getting error when run react-native run-android

The solution recommended there is close to Sutani one, that is editing node_modules/react-native-fbsdk/android/build.gradle and adding

compile('com.facebook.android:facebook-android-sdk:4.28.0')

It seems not to be a regression introduced by react-native-fbsdk but by Google Android libraries but I am not 100% clear about it.

like image 24
Philippe Cohen Avatar answered Oct 19 '22 06:10

Philippe Cohen