react-native-fb sdk com.android.support dependency error
Asked Answered
F

6

8
 > 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

Frosting answered 6/12, 2017 at 13:36 Comment(0)
D
16

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"
        }
      }
  }
Dot answered 9/12, 2017 at 10:55 Comment(2)
Thankyou, when i add maven.google.com , it download the missing items . but in my case, I also had to change my android/app/build.gradle and android/build.gradle to 26 , 27.0.2Cockiness
Yes You Will have Update Project : android/app/build.gradle and all those Libraries which you LINK in your Project . FBSDK : android/build.gradle to 26 , 27.0.2 @CockinessDot
P
6

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.

Poetess answered 7/12, 2017 at 8:22 Comment(0)
N
0

i have same problem, and i solved with :

  1. edit package.json and i am edit react-native-fbsdk from react-native-fbsdk": "0.6.3" to react-native-fbsdk": "0.6.0"

  2. go to your node_modules/react-native-fbsdk/android/build.gradle. open build.gradle file.

  3. Change compile('com.facebook.android:facebook-android-sdk:4++') to compile('com.facebook.android:facebook-android-sdk:4.22.1'),

but I don't know if this is the best way for this problem, thank you

Nombles answered 6/12, 2017 at 16:18 Comment(0)
C
0
CUR_SPACE=.
culpritLocation=$CUR_SPACE/node_modules/react-native-fbsdk/android/build.gradle

sed -i -e 's/com.facebook.android:facebook-android-sdk:4.+/com.facebook.android:facebook-android-sdk:4.26.0/' $culpritLocation

printf "Fixed Could not resolve all dependencies for configuration ':react-native-fbsdk:_debugPublishCopy'.\n> Could not find com.android.support:appcompat-v7:27.0.1."
printf "fix_rn_fbsdk_google_libraries.sh should be removed at a later time\n"

Place the above script in the root of your react-native project, add executing permissions to it, then in package.json within the postinstall property add ./your-script-name.sh;. Ex:

{
  "name": "AppName",
  "version": "1.28.14",
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "postinstall": "./fix_rn_fbsdk_google_libraries.sh; ./infuse_version.sh;"
  },
  [..]
}

If you're not familiar with postinstall scripts, they'll run immediately after running npm install / yarn command.

The proposed solution works with cloud build tools :) and it is only temporary. Future rn-fbsdk releases should fix the issue.

Concern answered 7/12, 2017 at 9:42 Comment(2)
can you describe your answer more to make clear understanding.Mucoprotein
As mentioned in the original comment, you'd have to create a file your-script-name.sh in the root folder of the project, then add if not already using the postinstall attribute in your package.json file. If the script has execution permission and the contents are the ones in the original answer it will fix the issue.Concern
F
0

The key is in the error message shown in your case:

Searched in the following locations: file:/<location_to_sdk>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/27.0.1/

I have had the same. Then I went to the location:

file:<location_to_sdk>/sdk/extras/android/m2repository/com/android/support/appcompat-v7/

And found that there is no directory named 27.0.1 because in my case the latest buildTool was not downloaded. In my case I have had 27.0.0-alpha1.

So in both of my app build.gradle and in

node_modules/react-native-fbsdk/android/build.gradle

I replaced 27.0.1 with 27.0.0-alpha1 and build was successful.

Forestforestage answered 8/12, 2017 at 4:48 Comment(0)
H
0

build.gradle --- app

dependencies {
    compile 'com.facebook.react:react-native:+' // support react-native-v0.22-rc+
    compile('com.facebook.android:facebook-android-sdk:4.+')
}

    allprojects {
        repositories {
            configurations.all {
                resolutionStrategy {
                    force 'com.facebook.android:facebook-android-sdk:4.28.0'
                }
            }
        }
    }


Solution:

How to fix the file permissions, after loading end react-native start

First, Go to android folder

cd android

Now clean the project...

gradlew clean //for Mac users, change gradlew to ./gradlew

Now run the build process again in the root folder 
cd ..
react-native run-android

Solved Issue Happy Coding!
Hoag answered 27/12, 2018 at 5:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.