在android studio上将实时数据库添加到我的应用程序 - 无法解决:firebase-database-15.0.0

问题描述 投票:0回答:2

我一直在使用firebase来访问我项目中的活动。一切正常,没有编译错误。然而,在我去工具> firebase后,我可以轻松连接到我的应用程序,但是当我尝试单击添加实时数据库时,它向我显示:

build.gradle will include these new dependencies:
    compile 'com.google.firebase:firebase-database:16.0.1:15.0.0'

由于编译被弃用,我使用实现,当我这样做

实施'com.google.firebase:firebase-database:16.0.1:15.0.0'

我收到以下错误无法解决:firebase-database-15.0.0

我的同步失败了。

android firebase
2个回答
0
投票

在项目级gradle中添加jcenter()

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

并继续留下@Tomin B说。


1
投票

将根Gradle更改为

buildscript {
    // ...
    dependencies {
        // ...
        classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
    }
}

allprojects {
    // ...
    repositories {
        // ...
        google() // Google's Maven repository
    }
}

和App Gradle To

apply plugin: 'com.android.application'

android {
  // ...
}

dependencies {
  // ...
  implementation 'com.google.firebase:firebase-core:16.0.1'
  implementation 'com.google.firebase:firebase-database:16.0.1'

  // Getting a "Could not find" error? Make sure you have
  // added the Google maven respository to your root build.gradle
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

希望这可以帮助你

© www.soinside.com 2019 - 2024. All rights reserved.