Failed to resolve: com.facebook.android:facebook-a

2019-04-25 07:15发布

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" }
    }
}

7条回答
该账号已被封号
2楼-- · 2019-04-25 07:46

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.

查看更多
聊天终结者
3楼-- · 2019-04-25 07:53

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楼-- · 2019-04-25 08:00

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.

查看更多
5楼-- · 2019-04-25 08:03

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'

查看更多
▲ chillily
6楼-- · 2019-04-25 08:04

Try the below dependency. It worked for me

compile 'com.facebook.android:facebook-android-sdk:[4,5)'
查看更多
三岁会撩人
7楼-- · 2019-04-25 08:10

Try below, works perfect for me

    implementation 'com.facebook.android:facebook-android-sdk:[4,5]'
查看更多
登录 后发表回答