25

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" }
    }
}
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Vinayak B
  • 4,430
  • 4
  • 28
  • 58
  • 1
    Try removing the dependencies and re-adding them and then Clean Build the project again. Also, make sure your Studio and all Services are updated. – Kartik Shandilya Sep 29 '17 at 04:50
  • I think It's repository error. Right now its working . I re-added everything one by one. Thanks for your replay – Vinayak B Sep 29 '17 at 04:53

17 Answers17

34

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.

Pravinsingh Waghela
  • 2,516
  • 4
  • 32
  • 50
14

Use this dependency for Facebook SDK. It will work. (Tested on Android Studio version 3.0 and above)

implementation 'com.facebook.android:facebook-login:4.30.0'
Pang
  • 9,564
  • 146
  • 81
  • 122
Himanshu Rawat
  • 658
  • 5
  • 13
10

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'

Pinak Gauswami
  • 789
  • 6
  • 10
7

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

Muhammad Haidar
  • 1,541
  • 16
  • 17
7

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

Dror Bar
  • 686
  • 2
  • 10
  • 19
5

If you are using android studio below 3.0 version then Try this: Replace the dependency compile 'com.facebook.android:facebook-android-sdk:4.26.0'

Gaurav sappal
  • 81
  • 1
  • 5
4

Try below, works perfect for me

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

try to add

implementation 'com.facebook.android:facebook-core:[8,9)'
implementation 'com.facebook.android:facebook-login:[8,9)'
bebosh
  • 806
  • 10
  • 25
2

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.

Kartik Shandilya
  • 3,796
  • 5
  • 24
  • 42
2

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)'
}
Gopal Meena
  • 407
  • 8
  • 20
2

Worked for me:

implementation 'com.facebook.android:audience-network-sdk:5.5.0'
Ashish Virani
  • 182
  • 1
  • 15
2

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

Anand M Joseph
  • 787
  • 7
  • 7
1

Try the below dependency. It worked for me

compile 'com.facebook.android:facebook-android-sdk:[4,5)'
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
Mushfiq
  • 19
  • 2
1

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)).

Vikram Ragu
  • 169
  • 1
  • 8
0

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'
yacine
  • 147
  • 1
  • 6
0

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.

Oscar
  • 157
  • 1
  • 9
0

Had same issue, fixed it by changing

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

to

implementation 'com.facebook.android:facebook-android-sdk:4.30.0'

in app/build.gradle

Ganesh Garad
  • 381
  • 2
  • 6