无法解决:com.google.firebase:firebase-database:11.4.2

时间:2017-11-03 14:39:50

标签: android maven android-studio firebase firebase-realtime-database

我添加了依赖项,并将maven {url“https://maven.google.com”}添加到我的build.gradle文件中。但仍然会出现错误:

  

无法解析com.google.firebase:firebase-database:11.4.2

     

无法解析com.google.firebae:firebase-core:11.4.2

这是root one

中的 build.gradle 文件
buildscript {
repositories {
    jcenter()
    mavenLocal()
}
dependencies {
    classpath 'com.android.tools.build:gradle:2.2.2'
    classpath 'com.google.gms:google-services:3.1.0'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

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

task clean(type: Delete) {
    delete rootProject.buildDir
}

以下是app one

中的 build.gradle 文件
apply plugin: 'com.android.application'

repositories {
    mavenLocal()
    flatDir {
       dirs 'libs'
    }
}

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.google.firebase.udacity.friendlychat"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 
'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'

    compile 'com.android.support:design:24.2.0'
    compile 'com.android.support:appcompat-v7:24.2.0'

    compile 'com.google.firebase:firebase-core:11.4.2'

    compile 'com.google.firebase:firebase-database:11.4.2'

    // Displaying images
    compile 'com.github.bumptech.glide:glide:3.6.1'
}
apply plugin: 'com.google.gms.google-services'

这里有任何帮助!

1 个答案:

答案 0 :(得分:0)

compileSdkVersion更新至至少26.来自https://developers.google.com/android/guides/releases

“当您将应用的Play服务依赖项升级到11.2.0或更高版本时,还必须更新您应用的build.gradle以指定至少为26(Android O)的compileSdkVersion。”