android firebase在gradle中添加依赖项时显示错误

时间:2017-11-18 03:36:51

标签: android gradle dependencies

添加依赖项后出错:

enter image description here

这是我的build.gradle应用代码,其中我添加了编译com.google.firebase:firebase-core:11.6.0' 编译com.google.firebase:firebase-database:11.6.0'依赖。以下评论。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 26
    buildToolsVersion "26.0.2"
    defaultConfig {
        applicationId "com.example.thelost.fisp_beta10"
        minSdkVersion 16
        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'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:26.+'
    compile 'com.android.support:recyclerview-v7:26.+'
    compile 'com.android.support:design:26.+'
    compile 'com.android.support:cardview-v7:26.+'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    testCompile 'junit:junit:4.12'

    //for the firebase
    compile 'com.google.firebase:firebase-core:11.6.0'
    compile 'com.google.firebase:firebase-database:11.6.0'
}
//for the firebase
apply plugin: 'com.google.gms.google-services'

1 个答案:

答案 0 :(得分:1)

在根build.gradle文件中添加repo:

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

如果您使用gradle 4.0或更高版本,则可以仅使用maven { url "https://maven.google.com" }替换google()