编译'com.facebook.android:facebook-share:[4,5)的Gradle错误''

时间:2018-01-20 15:48:35

标签: android android-studio build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion '26.0.1'
    defaultConfig {
        applicationId "com.android.login_androidlogin"
        minSdkVersion 23
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    //CounterFAB
    compile 'com.github.andremion:counterfab:1.0.1'
    compile 'com.facebook.android:facebook-share:[4,5)'

    compile 'com.github.d-max:spots-dialog:0.7@aar'
    compile 'io.paperdb:paperdb:2.1'
    compile 'com.stepstone.apprating:app-rating:2.0.0'
    compile 'com.github.rey5137:material:1.2.4'
    compile 'com.github.mancj:MaterialSearchBar:0.7.1'
    compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
    compile 'com.cepheuen.elegant-number-button:lib:1.0.2'
    compile 'com.android.support:design:26.+'
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.google.firebase:firebase-core:10.2.0'
    compile 'com.google.firebase:firebase-database:10.2.0'
    compile 'info.hoang8f:fbutton:1.0.5'
    compile 'com.rengwuxian.materialedittext:library:2.1.4'
    compile 'com.android.support:cardview-v7:26.+'
    compile 'com.android.support:recyclerview-v7:26.+'
    compile 'com.firebaseui:firebase-ui-database:1.2.0'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

将build com.facebook.android:facebook-share:[4,5)添加到build.gradle后,它会显示错误。

Error:Failed to resolve: com.android.support:support-annotations:27.0.1
Error:Failed to resolve: com.android.support:appcompat-v7:27.0.1
Error:Failed to resolve: com.android.support:customtabs:27.0.1
Error:Failed to resolve: com.android.support:cardview-v7:27.0.1
Error:Failed to resolve: com.android.support:support-v4:27.0.1
Error:Failed to resolve: com.android.support:support-core-utils:27.0.1

那么问题是什么以及如何解决? 在添加编译com.facebook.android:facebook-share:[4,5)

之前,所有代码都运行良好

1 个答案:

答案 0 :(得分:0)

要从版本26.0.0开始使用支持库,您需要将Google的Maven存储库添加到项目的build.gradle文件中,如下所述:https://developer.android.com/topic/libraries/support-library/setup.html

allprojects {
        repositories {
            jcenter()
            maven {
                url "https://maven.google.com"
            }
        }
    }

对于Android Studio 3.0.0及更高版本,您可以像这样编写google()

allprojects {
        repositories {
            jcenter()
            google()
        }
    }

对于Facebook SDK,您必须将mavenCentral()添加到buildscript { repositories {}}部分,如下所述: https://developer.android.com/topic/libraries/support-library/setup.html

像这样:

buildscript {
    repositories {
        mavenCentral() 
    }
}

您还可以指定类似

的版本
compile 'com.facebook.android:facebook-share:4.28.0'

而不是[4,5)

你可以从他们的github获得最新版本: https://github.com/facebook/facebook-android-sdk