无法解析:com.facebook.android:facebook-android-sdk:4.4.0

无法解析:com.facebook.android:facebook-android-sdk:4.4.0

问题描述:

以下是我的 build.gradle 文件中的代码.

Below is code from my build.gradle file.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "23.0.0 rc3"

    defaultConfig {
        applicationId "com.example.test"
        minSdkVersion 14
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
   mavenCentral()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.facebook.android:facebook-android-sdk:4.4.0'
}

当我用 gradle 文件同步项目时,它给了我错误.

When I do Sync project with gradle files, it gives me error.

  Error:(28, 13) Failed to resolve: com.facebook.android:facebook-android-sdk:4.4.0

谁能告诉我为什么我会收到这个错误?

Can anyone tell me why I'm getting this error?

这里有人问过类似的问题,但没有人回答.(无法解析:com.facebook.android:facebook-android-sdk:4.0.0 )

Similar question has been asked here but no one has answered it. ( Failed to resolve: com.facebook.android:facebook-android-sdk:4.0.0 )

花了 6-8 个小时终于搞定了.我为你找到了解决方案.您只需更改应用程序 build.gradle 文件中的存储库部分.将其从 mavenCentral 更改为 jcenter 如下

Finally after spending 6-8 hours on it. I got the solution for you. You have to just change repositories section in your app build.gradle file. change it from mavenCentral to jcenter as following

repositories {
    jcenter {
        url "http://jcenter.bintray.com/"
    }    
}

有了这个之后,你可以简单地将依赖添加为

After having this, You can simply add the dependency as

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