简体   繁体   English

解析失败:com.google.firebase:firebase-core:9.0.0

[英]Failed to resolve: com.google.firebase:firebase-core:9.0.0

I get the following error while upgrading a firebase project from old domain to new google firebase domain.将 firebase 项目从旧域升级到新的 google firebase 域时出现以下错误。

Failed to resolve: com.google.firebase:firebase-core:9.0.0解析失败:com.google.firebase:firebase-core:9.0.0

I followed the steps mentioned on the Firebase documentation , in the section Add Firebase to your Android Project, topic Available libraries .我遵循了Firebase 文档中提到的步骤,在将 Firebase 添加到您的 Android 项目部分,主题可用库中。

What are my options to resolve this error?我有哪些解决此错误的选项?

Update Aug 2017 2017 年 8 月更新

As of version 11.2.0 Firebase and Google Play services dependencies are available via Google's Maven Repo .11.2.0版本开始,Firebase 和 Google Play 服务依赖项可通过Google 的 Maven Repo 获得 You no longer need to use the Android SDK manager to import these dependencies.您不再需要使用 Android SDK 管理器来导入这些依赖项。

In your root build.gradle file add the repo:在您的根build.gradle文件中添加 repo:

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

If you are using gradle 4.0 or higher you can replace maven { url "https://maven.google.com" } with just google() .如果您使用的是 gradle 4.0或更高版本,您可以将maven { url "https://maven.google.com" }替换为google()


The 9.0.0 version of Firebase was built using Google Play services 9.0 and is now available under the new packaging com.google.firebase:* Firebase 9.0.0版本是使用 Google Play 服务 9.0 构建的,现在可以在新包装com.google.firebase:*

See Release Notes for Google Play services 9.0 https://developers.google.com/android/guides/releases#may_2016_-_v90请参阅 Google Play 服务 9.0 的发行说明https://developers.google.com/android/guides/releases#may_2016_-_v90

New versions of packages Google Play Services (rev 30) and Google Repository (rev 26) were just released in the SDK manager so it's likely you just need to update.新版本的包Google Play Services (rev 30) 和Google Repository (rev 26) 刚刚在 SDK 管理器中发布,因此您可能只需要更新。


Downloading Google Play Services and Google Repository下载 Google Play 服务和 Google 存储库

From Android Studio:来自安卓工作室:

  1. Click Tools > Android > SDK Manager .单击Tools > Android > SDK Manager
  2. Click into the SDK Tools tab.单击进入SDK Tools选项卡。
  3. Select and install Google Play Services (rev 30) and Google Repository (rev 26).选择并安装Google Play Services (rev 30) 和Google Repository (rev 26)。 See the image below.见下图。
  4. Sync and Build your project. SyncBuild您的项目。

在此处输入图片说明


From IntelliJ IDEA:来自 IntelliJ IDEA:

As of April 2017, the latest versions of Google Play Services and Repository are listed below.截至 2017 年 4 月,下面列出了最新版本的 Google Play 服务和存储库。

  1. Click Tools > Android > SDK Manager .单击Tools > Android > SDK Manager
  2. Under the Packages panel, Look for the Extras .Packages面板下,查找Extras
  3. Select and install Google Play Services (rev 39) and Google Repository (rev 46).选择并安装Google Play Services (rev 39) 和Google Repository (rev 46)。 See the image below.见下图。
  4. Perform a gradle project sync and Build your project. Perform a gradle project syncBuild您的项目。

截至 2017 年 4 月更新了 SDK 管理器的图像

Go to Android SDK Manager and install the latest version of below two libraries转到 Android SDK Manager 并安装以下两个库的最新版本

  1. Google Play Services谷歌播放服务
  2. Google Repository谷歌存储库

Error:(30, 13) Failed to resolve: com.google.firebase:firebase-auth:9.6.1

If you ever get this error and you are using Android studio 2.2 that comes with firebase component integrated in it which has libraries version 9.6.0 by default and you are adding the latest dependencies like 9.6.1 .如果您遇到此错误,并且您使用的是集成了 firebase 组件的 Android studio 2.2,默认情况下该组件具有库版本 9.6.0,并且您正在添加最新的依赖项,例如 9.6.1 。 You might need to downgrade com.google.firebase:firebase-auth:9.6.1 to com.google.firebase:firebase-auth:9.6.0您可能需要将com.google.firebase:firebase-auth:9.6.1降级为com.google.firebase:firebase-auth:9.6.0

Or check the library version of your pre-installed firebase and make sure it is of the same version with the new library you are trying to add or added to your project.或者检查您预安装的 firebase 的库版本,并确保它与您尝试添加或添加到项目中的新库的版本相同

Tried all the above, use the Firebase Assistant !尝试了以上所有方法,使用Firebase 助手 It is the simplest way to solve this.这是解决这个问题的最简单方法。 First remove all the dependencies you added to the build.gradle (using the manual method) and then in Android Studio:首先删除你添加到 build.gradle 的所有依赖项(使用手动方法),然后在 Android Studio 中:

Click Tools > Firebase to open the Assistant window.

It really is as easy as that.真的就是这么简单。

Faced myself and seen several times in comments for similar questions - that even after installing "latest" Google Play Services and Google Repository still having the same issue.面对自己并在类似问题的评论中多次看到 - 即使在安装“最新”的Google Play 服务Google 存储库后仍然存在相同的问题。

The thing is that they may be latest for your current revision of Android SDK Tools , but not that latest your app build requires.问题是它们可能是您当前版本的Android SDK Tools 的最新版本,但不是您的应用程序构建所需的最新版本。

In such case make sure to install latest version of Android SDK Tools first, and probably Android SDK Platform-tools (both under Tools branch).在这种情况下,请确保首先安装最新版本的Android SDK Tools ,可能还有Android SDK Platform-tools (都在Tools分支下)。 Also please note you may need to go through this several times if you haven't updated for a long time (ie install latest Android SDK Tools and Android SDK Platform-tools , then restart Android SDK Manager, then repeat), since the updates seem to be going through some critical mandatory milestones and you cannot install the very latest if you currently have the revision which is pretty "old".另请注意,如果您长时间没有更新(即安装最新的Android SDK ToolsAndroid SDK Platform-tools ,然后重新启动 Android SDK Manager,然后重复),您可能需要多次执行此操作,因为更新似乎正在经历一些关键的强制性里程碑,如果您当前拥有相当“旧”的修订版,则无法安装最新版本。

Android SDK 管理器 - 工具和平台工具

dependencies {
    compile 'com.google.android.gms:play-services-maps:11.8.0'
    compile 'com.google.android.gms:play-services-auth:11.8.0'
    compile 'com.google.android.gms:play-services-ads:11.8.0'
    compile 'com.google.firebase:firebase-storage:11.8.0'

}
apply plugin: 'com.google.gms.google-services'


// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {


        maven { url 'https://maven.fabric.io/public' }

        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.google.gms:google-services:3.1.1'


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

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

Following are the prerequisites if you want to add firebase to your project.如果您想将 firebase 添加到您的项目,以下是先决条件。

  1. For working with Firebase you should install Android Studio 1.5 or higher.要使用 Firebase,您应该安装 Android Studio 1.5 或更高版本。
  2. Download the latest Google Play services SDK from through Android SDK Manager.通过 Android SDK 管理器下载最新的 Google Play 服务 SDK。
  3. The device should be running Android 2.3 (Gingerbread) or newer, and Google Play services 9.2.0 or newer.设备应运行 Android 2.3 (Gingerbread) 或更高版本,以及 Google Play 服务 9.2.0 或更高版本。

I could only find out all this after hours of struggle.经过几个小时的斗争,我只能找到这一切。

Source: Adding Firebase to your Android App来源: 将 Firebase 添加到您的 Android 应用

If using command line tools, do如果使用命令行工具,请执行

sdkmanager 'extras;google;m2repository'
sdkmanager 'extras;android;m2repository'

Need to Update需要更新

Android SDK : SDK Tools -> Support Repository -> Google Repository Android SDK : SDK Tools -> Support Repository -> Google Repository

After updating the Android SDK need to sync gradle build in Android studio.更新 Android SDK 后需要在 Android Studio 中同步 gradle build。

In my case, on top of adding google() in repositories for the project level gradle file, I had to also include it in the app level gradle file.就我而言,除了在项目级 gradle 文件的存储库中添加 google() 之外,我还必须将其包含在应用程序级 gradle 文件中。

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

If all the above methods are not working then change implementation 'com.google.firebase:firebase-core:12.0.0' to implementation 'com.google.firebase:firebase-core:10.0.0' in your app level build.gradle file.如果上述所有方法都不起作用,则在您的应用级别 build.gradle 中将implementation 'com.google.firebase:firebase-core:12.0.0'更改为implementation 'com.google.firebase:firebase-core:10.0.0'文件。 This would surely work.这肯定会奏效。

I tried all the solutions and nothing worked for me.我尝试了所有解决方案,但没有任何效果对我有用。 Changing gradle version worked for me.更改 gradle 版本对我有用。

I changed following inside gradle-wrapper.properties我在gradle-wrapper.properties里面gradle-wrapper.properties

from来自

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

to

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

Update October 2022 2022 年 10 月更新

com.google.firebase-core has been deprecated in October 2022. Instead of firebase-core , use firebase-analytics or firebase-analytics-ktx . com.google.firebase-core已于 2022 年 10 月弃用。使用firebase-analyticsfirebase-analytics-ktx firebase-core

The firebase-core library is deprecated and no further versions will be released. firebase-core 库已弃用,不会发布更多版本。 This SDK included the Firebase SDK for Google Analytics.这个 SDK 包括谷歌分析的 Firebase SDK。

Now, to use Google Analytics or a product that recommends adding Google Analytics, you need to explicitly declare the Analytics dependency: com.google.firebase:firebase-analytics or com.google.firebase:firebase-analytics-ktx.现在,要使用Google Analytics或推荐添加Google Analytics的产品,需要显式声明Analytics依赖:com.google.firebase:firebase-analytics或com.google.firebase:firebase-analytics-ktx。

Release notes 发行说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM