简体   繁体   English

无法解析:com.google.firebase:firebase-core:16.0.1

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

I'm trying to add firebase cloud storage to my app.我正在尝试将 firebase 云存储添加到我的应用程序中。 Below is the app build.gradle.下面是应用程序 build.gradle。 But it says: Failed to resolve: com.google.firebase:firebase-core:16.0.1.但它说:无法解析:com.google.firebase:firebase-core:16.0.1。 Why?为什么? There is no firebase-core in the dependencies at all.依赖项中根本没有 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'

From the docs:-从文档: -

Your app gradle file now has to explicitly list com.google.firebase:firebase-core as a dependency for Firebase services to work as expected.您的应用程序 gradle 文件现在必须明确列出com.google.firebase:firebase-core作为 Firebase 服务按预期工作的依赖项。

Add:添加:

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

and in top level gradle file use the latest version of google play services:并在顶级 gradle 文件中使用最新版本的 google play 服务:

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

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

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

Note:笔记:

You need to add the google() repo in the top level gradle file, as specified in the firebase docs and also it should be before jcenter() :您需要在顶级 gradle 文件中添加google()存储库,如 firebase 文档中所述,并且它应该在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 https://firebase.google.com/docs/android/setup

Since May 23, 2018 update , when you're using a firebase dependency, you must include the firebase-core dependency, too.20185 月 23 日更新以来,当您使用 firebase 依赖项时,您也必须包含firebase-core依赖项。

If adding it, you still having the error, try to update the gradle plugin in your gradle-wrapper.properties to 4.5 version:如果添加它,你仍然有错误,请尝试更新您的gradle这个插件gradle-wrapper.properties到4.5版:

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

and resync the project.并重新同步项目。

Add maven { url " https://maven.google.com " } to your root level build.gradle file将 maven { url " https://maven.google.com " } 添加到您的根级 build.gradle 文件中

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

As @Peter Haddad mentioned above,正如@Peter Haddad 上面提到的,

To fix this issue I followed Google firebase integration guidelines and did the following changes in my app/build.gradle and project/build.gradle为了解决这个问题,我遵循了 Google firebase 集成指南,并在我的 app/build.gradle 和 project/build.gradle 中做了以下更改

Follow below mentioned link if you have any doubts如果您有任何疑问,请按照下面提到的链接

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

changes in app/build.gradle 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"

Changes in Project/build.gradle 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" } } }

I get the same issue and i solved it by replacing :我遇到了同样的问题,我通过替换解决了它:

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

to

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

and everything solved and worked well.一切都解决了并且运行良好。

What actually was missing for me and what made it work then was downloading'Google Play services' and 'Google Repository'我真正缺少的是下载“Google Play services”和“Google Repository”

Go to: Settings -> Android SDK -> SDK Tools -> check/install Google Play services + repository转到:设置 -> Android SDK -> SDK 工具 -> 检查/安装 Google Play 服务 + 存储库

SDK 工具设置 SS

Hope it helps.希望能帮助到你。

I was able to solve the issue by following these steps-我能够按照以下步骤解决问题-

1.) This error occurs when you didn't connect your project to firebase. 1.) 当您没有将项目连接到 firebase 时会发生此错误。 Do that from Tools->Firebase if you are using Android studio version 2.2 or above.如果您使用的是 Android Studio 2.2 或更高版本,请从Tools->Firebase执行此操作。

2.) Make sure you have replaced the compile with implementation in dependencies in app/build.gradle 2.) 确保你已经用dependencies in app/build.gradle中的dependencies in app/build.gradle implementation替换了compile

3.) Include your firebase dependency from the firebase docs. 3.) 从 firebase 文档中包含您的 firebase 依赖项。 Everything should work fine now现在一切正常

This is rare, but there is a chance your project's gradle offline mode is enable, disable offline mode with the following steps;这种情况很少见,但有可能您的项目的 gradle 离线模式已启用,请按照以下步骤禁用离线模式;

  • In android studio, locate the file tab of the header and click在android studio中,找到header的file选项卡,点击
  • In the drop own menu, select settings在下拉菜单中,选择设置
  • In the dialog produced, select "Build, Execution, Deploy" and then select "Gradle"在生成的对话框中,选择“构建、执行、部署”,然后选择“Gradle”
  • Finally uncheck the "offline work" check box and apply changes最后取消选中“离线工作”复选框并应用更改

If this doesn't work leave a comment describing your Logcat response and i'll try to help more.如果这不起作用,请发表评论描述您的 Logcat 响应,我会尽力提供更多帮助。

就我而言,它是通过将 compileSdkVersion 和 targetSdkVersion 从 26 更改为 27 来解决的

If you use Firebase in a library module, you need to apply the google play services gradle plugin to it in addition to the app(s) module(s), but also, you need to beware of version 4.2.0 (and 4.1.0) which are broken, and use version 4.0.2 instead.如果您在库模块中使用 Firebase,除了应用模块之外,您还需要将 google play services gradle 插件应用到它,而且,您还需要注意 4.2.0(和 4.1.1.1)版本。 0) 已损坏,请改用 4.0.2 版。

Here's the issue: https://github.com/google/play-services-plugins/issues/22这是问题所在: https : //github.com/google/play-services-plugins/issues/22

if you are using如果你正在使用

compileSdkVersion 23

in app-level gradle, and在应用程序级别的gradle中,以及

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

in project-level gradle and you have added the google-services.json file to your project.在项目级 gradle 中,并且您已将 google-services.json 文件添加到您的项目中。

you need to add just below code你需要添加下面的代码

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

at below of jcenter() in repositories blocks in project-level gradle file here are my gradle files:在项目级 gradle 文件中的存储库块中的 jcenter() 下面是我的 gradle 文件:

project-level gradle file:项目级gradle文件:

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
}

and app-level gradle file:和应用程序级 gradle 文件:

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'

If you receive an error stating the library cannot be found, check the Google maven repo for your library and version.如果您收到说明找不到库的错误,请检查您的库和版本的 Google Maven 存储库。 I had a version suddenly disappear and make my builds fail.我有一个版本突然消失并使我的构建失败。

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

Go to

Settings -> Android SDK -> SDK Tools ->设置 -> Android SDK -> SDK 工具 ->

and make sure you install Google Play Services并确保您安装了 Google Play 服务

暂无
暂无

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

相关问题 “无法解决:com.google.firebase:firebase-core:9.0.0” - “Failed to resolve: com.google.firebase:firebase-core:9.0.0” Firebase设置-错误:无法解决:com.google.firebase:firebase-core:12.0.1 - Firebase set up- error: Failed to resolve: com.google.firebase:firebase-core:12.0.1 找不到参数[com.google.firebase:firebase-core:16.0.1]的方法Implementation() - Could not find method implementation() for arguments [com.google.firebase:firebase-core:16.0.1] 错误:无法解决:com.google.firebase:firebase-core:18.1.0在“项目结构”对话框中显示受影响的模块:app - ERROR: Failed to resolve: com.google.firebase:firebase-core:18.1.0 Show in Project Structure dialog Affected Modules: app 找不到参数的方法 implementation() [com.google.firebase:firebase-core:17.0.0] - Could not find method implementation() for arguments [com.google.firebase:firebase-core:17.0.0] Android构建错误com.google.firebase:firebase-core:16.0.8 - Android build error com.google.firebase:firebase-core:16.0.8 错误:无法解决:com.google.girebase:firebase-core:16.2.0 - ERROR: Failed to resolve: com.google.girebase:firebase-core:16.2.0 无法解析com.google.firebase:firebase-database:11.8.0 - Could not resolve com.google.firebase:firebase-database:11.8.0 无法解析 com.google.firebase:firebase-bom:[15.0.0, 16.0.0) - Could not resolve com.google.firebase:firebase-bom:[15.0.0, 16.0.0) “找不到 com.google.firebase:firebase 分析” - "Could not find com.google.firebase:firebase-analytics"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM