未能解决: com.google.firebase: firebase-core: 16.0.1

我正在尝试给我的应用程序添加火库云存储。下面是应用程序 build.gradle。但它显示: 未能解决: com.google.firebase: firebase-core: 16.0.1。 为什么? 在依赖项中根本没有 firebase-core。

apply plugin: 'com.android.application'


android {
compileSdkVersion 27
defaultConfig {
applicationId "com.louise.udacity.mydict"
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}


dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'


implementation 'com.google.cloud:google-cloud-storage:1.31.0'
implementation 'com.firebase:firebase-jobdispatcher:0.8.5'
}


apply plugin: 'com.google.gms.google-services'
126988 次浏览

来自文件:-

您的应用程序级别文件现在必须明确列出 com.google.firebase:firebase-core作为 Firebase 服务的一个依赖项才能按预期工作。

地址:

 implementation 'com.google.firebase:firebase-core:16.0.1'

并在顶级档案中使用最新版本的谷歌播放服务:

classpath 'com.google.gms:google-services:4.0.2'

Https://firebase.google.com/support/release-notes/android

Https://bintray.com/android/android-tools/com.google.gms.google-services

注:

你需要添加 google()回购在最高级别的年级文件,如指定的文档,而且它应该在 jcenter():

 buildscript {
repositories {
google()
jcenter()
}






dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.2'
}
}


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


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

Https://firebase.google.com/docs/android/setup

因为 2018年5月23日更新,当您使用一个 firebase 依赖项时,您必须也包含 firebase-core依赖项。

如果你添加了它,你仍然有错误,尝试更新你的 gradle-wrapper.properties的 gradle 插件到4.5版本:

distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-all.zip

重新同步项目。

我得到了同样的问题,我解决了它通过替换:

implementation 'com.google.firebase:firebase-core:16.0.1'

implementation 'com.google.firebase:firebase-core:15.0.2'

一切都解决了,运转良好。

我能够通过以下步骤解决这个问题-

当您没有将您的项目连接到 firebase 时,会发生此错误。 如果您使用的是 Android 工作室版本2.2或更高版本,请从 工具-> Firebase进行操作。

2)确保你已经在 dependencies in app/build.gradle中用 implementation代替了 compile

3)包括你的 Firebase 依赖从 firebase 文档。现在一切都应该工作正常

将 maven { url“ https://maven.google.com”}添加到根级 build.gradle 文件

repositories {
maven { url "https://maven.google.com" }
flatDir {
dirs 'libs'
}
}

这是罕见的,但有一个机会,您的项目的分级脱机模式是启用,禁用脱机模式与以下步骤;

  • 在 android 工作室中,找到标题的文件选项卡并单击
  • 在下拉菜单中,选择设置
  • 在生成的对话框中,选择“ Build,Execution,Deploy”,然后选择“ Gradle”
  • 最后取消“脱机工作”复选框并应用更改

如果这不起作用,请留言描述您的 Logcat 响应,我将尝试提供更多帮助。

在我的例子中,解决方法是将 buildeSdkVersion 和 targetSdkVersion 从26更改为27

我真正缺少的是下载“ Google Play 服务”和“ Google Repository”

转到: Settings-> Android SDK-> SDK Tools-> check/install Google Play services + itory

SDK Tools Settings SS

希望能有帮助。

如果你在图书馆模块中使用 Firebase,除了应用程序模块之外,你还需要在它上面应用 google play services gradle 插件,但是,你还需要注意4.2.0(和4.1.0)版本已经坏了,改用4.0.2版本。

问题是: https://github.com/google/play-services-plugins/issues/22

正如@Peter Haddad 上面提到的,

为了解决这个问题,我遵循了 Google firebase 集成指南,在 app/build.gradle 和 project/build.gradle 中做了以下修改

如果你有任何疑问,请点击下面提到的链接

Https://firebase.google.com/docs/android/setup

App/build.gradle 的变化

implementation 'com.google.android.gms:play-services-base:15.0.2'
implementation "com.google.firebase:firebase-core:16.0.1"
implementation "com.google.firebase:firebase-messaging:17.4.0"

Project/build.gradle 中的更改

repositories {


google()
jcenter()
mavenCentral()
maven {
url 'https://maven.fabric.io/public'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.2.0'// // google-services plugin it should be latest if you are using firebase version 16.0 +
       

}
allprojects {
repositories {
google()// add it to top instead of bottom or somewhere in middle
mavenLocal()
mavenCentral()
maven {
url 'https://maven.google.com'
}
       

jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
        

}
}

如果你正在使用

compileSdkVersion 23

在应用程序级别,和

classpath 'com.android.tools.build:gradle:2.1.0'

在项目级别的分级 你已经添加了 Google-services. json 文件到您的项目。

您需要在代码下面添加

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

在项目级的 gradle 文件中的存储库块的 jcenter ()的下面 这是我的档案:

项目级别的档案:

buildscript {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.google.gms:google-services:4.0.1'


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


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


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

以及应用程序级别的分级文件:

apply plugin: 'com.android.application'


android {
compileSdkVersion 23
buildToolsVersion "23.0.3"


defaultConfig {
applicationId "com.example.moslem.amazonlikeapp"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}


dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'

只需添加以下代码,并更新所有可用的 Firebase 版本

 implementation 'com.google.firebase:firebase-core:17.2.0'

如果您收到一个错误,说明库无法找到,检查您的库和版本的谷歌专家回购。我有一个版本突然消失,使我的构建失败。

Https://maven.google.com/web/index.html

去吧

设置-> Android SDK-> SDK Tools->

并确保你安装了谷歌播放服务