问题
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" }
}
}
回答1:
Follow the below procedure to resolve the issue:-
Click on
Project Structure
from the icon available in thetool bar
above.Open
Dependencies
tab.select
com.facebook.android:facebook-android-sdk:[4,5)
Remove the facebook dependency by clicking the minus(
-
) button on the extreme right side.Now, Click on Plus(
+
) button on the right side above Minus button. SelectLibrary dependency
Type
Facebook
on the search input box and click on the search button.Choose
com.facebook.android:facebook-login
. click onOk
. Sync your Gradle.
This will resolve your issue. As it has worked for me.
回答2:
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'
回答3:
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'
回答4:
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'
回答5:
Try below, works perfect for me
implementation 'com.facebook.android:facebook-android-sdk:[4,5]'
回答6:
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.
回答7:
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)'
}
回答8:
Try the below dependency. It worked for me
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
回答9:
This solution worked for me:
implementation 'com.facebook.android:audience-network-sdk:5.4.1'
回答10:
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.
回答11:
Worked for me:
implementation 'com.facebook.android:audience-network-sdk:5.5.0'
来源:https://stackoverflow.com/questions/46481942/failed-to-resolve-com-facebook-androidfacebook-android-sdk4-5