Failed to resolve: com.facebook.android:facebook-android-sdk:[4,5)

Viewed 44773

I am using facebook sdk in my project. Facebook SDK works fine till yesterday. but today when I open my project , the build failed and shows error as follows

 Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
   > Could not resolve com.facebook.android:facebook-android-sdk:[4,5).
     Required by:
         project :app
      > Could not resolve com.facebook.android:facebook-android-sdk:[4,5).
         > Failed to list versions for com.facebook.android:facebook-android-sdk.
            > Unable to load Maven meta-data from https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/maven-metadata.xml.
               > Could not GET 'https://jcenter.bintray.com/com/facebook/android/facebook-android-sdk/maven-metadata.xml'.
                  > jcenter.bintray.com
      > Could not resolve com.facebook.android:facebook-android-sdk:[4,5).
         > Failed to list versions for com.facebook.android:facebook-android-sdk.
            > Unable to load Maven meta-data from https://jitpack.io/com/facebook/android/facebook-android-sdk/maven-metadata.xml.
               > Could not GET 'https://jitpack.io/com/facebook/android/facebook-android-sdk/maven-metadata.xml'.
                  > jitpack.io

I tries clean & build and also inavalidate caches .but nothing worked. Also tries some stackoverflow solutions. none of them worked for me

this my repository in build.gradle

 repositories {
    jcenter()
    mavenCentral()
}
allprojects {
    repositories {
        jcenter()
        maven { url "https://jitpack.io" }
    }
}
16 Answers

Follow the below procedure to resolve the issue:-

  1. Click on Project Structure from the icon available in the tool bar above.

  2. Open Dependencies tab.

  3. select

    com.facebook.android:facebook-android-sdk:[4,5)

  4. Remove the facebook dependency by clicking the minus(-) button on the extreme right side.

  5. Now, Click on Plus(+) button on the right side above Minus button. Select Library dependency

  6. Type Facebook on the search input box and click on the search button.

  7. Choose com.facebook.android:facebook-login. click on Ok. Sync your Gradle.

This will resolve your issue. As it has worked for me.

remove compile 'com.facebook.android:facebook-android-sdk:[4,5)'

And add below dependency it resolve my problem

compile 'com.facebook.android:facebook-android-sdk:4.26.0'

If your react-native version is >= 9.3.0+ you can solve this issue by just removing and adding some lines:

 1)Remove this line from app/build.gradle ===>
 implementation 'com.facebook.android:facebook-android-sdk:[5,6)'

 2)Add this line in app/build.gradle ===>
  implementation 'com.facebook.android:facebook-android- 
  sdk:latest.release'

 3)Add this in android/build.gradlew 
 allprojects {
repositories {


    google()
    mavenLocal()
    maven {
        // Android JSC is installed from npm
        url("$rootDir/../node_modules/jsc-android/dist")
    }
   mavenCentral().  <====== Add this
    google()
    jcenter()
    maven { url 'https://www.jitpack.io' }
  }
}

4)At the end run gradlew clean command

In the file android/build.gradle try to replace each jcenter() with gradlePluginPortal()

Try below, works perfect for me

    implementation 'com.facebook.android:facebook-android-sdk:[4,5]'

try to add

implementation 'com.facebook.android:facebook-core:[8,9)'
implementation 'com.facebook.android:facebook-login:[8,9)'

Remove the dependencies and then just re-add the dependencies one by one. Finally Clean Build the Project and it should work.

A Studio or a library update may sometimes cause this type of issue.

Add this to Module-level /app/build.gradle before dependencies:

repositories {
  // You can also use jcenter if you prefer
  mavenCentral() 
}

Add the compile dependency you need with the latest version of the Facebook SDK in the build.gradle file:

dependencies { 
  // Facebook SDK Core only (Analytics)
  compile 'com.facebook.android:facebook-core:[5,6)'
  // Facebook Login only
  compile 'com.facebook.android:facebook-login:[5,6)'
  // Facebook Share only
  compile 'com.facebook.android:facebook-share:[5,6)'
  // Facebook Places only
  compile 'com.facebook.android:facebook-places:[5,6)'
  // Facbeook Messenger only
  compile 'com.facebook.android:facebook-messenger:[5,6)'
  // Facebook App Links only
  compile 'com.facebook.android:facebook-applinks:[5,6)'
  // Facebook Android SDK (everything)
  compile 'com.facebook.android:facebook-android-sdk:[5,6)'
  // Audience Network SDK. 
  compile 'com.facebook.android:audience-network-sdk:[5,6)'
  // Account Kit
  compile 'com.facebook.android:account-kit-sdk:[5,6)'
}

Worked for me:

implementation 'com.facebook.android:audience-network-sdk:5.5.0'

Release implementation 'com.facebook.android:facebook-login:[5,6)' with implementation 'com.facebook.android:facebook-login:5.15.1'

Try the below dependency. It worked for me

compile 'com.facebook.android:facebook-android-sdk:[4,5)'

Earlier I had different versions of facebook-android-sdk:[5,6) & facebook-applinks:[4,5). I made it the same version and it seems to build (facebook-applinks:[5,6)).

1- Make a search in google like this : facebook audience network sdk download
2- Go to the first result : https://developers.facebook.com/docs/audience-network/guides/adding-sdk/android
3- See the section of Manual download
latest facebook sdk version

4- You will find the latest version number (for example here : 6.0.0 or 5.11.0)
5- Add the dependency like this in your build.gradle(:app) :

implementation 'com.facebook.android:audience-network-sdk:6.2.1'

Just go to file -> re-import gradle project if you use Intelij or Android studio. I think it's a pretty simple solution. it worked for me.

Related