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

时间:2023-02-09 15:19:03

I'm trying to add firebase cloud storage to my app. Below is the app build.gradle. But it says: Failed to resolve: com.google.firebase:firebase-core:16.0.1. Why? There is no firebase-core in the dependencies at all.

我正在尝试将firebase云存储添加到我的应用程序中。下面是app 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'

3 个解决方案

#1


19  

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.0'

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.1'

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

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

Just to add, also you need to add the google() repo in the top level gradle file, as specified in the firebase docs:

只需添加,您还需要在*gradle文件中添加google()repo,如firebase文档中所指定:

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

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

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

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

#2


0  

Since May 23, 2018 update, when you're using a firebase dependency, you must include the firebase-core dependency, too.

自2018年5月23日更新以来,当您使用firebase依赖项时,您还必须包含firebase-core依赖项。

If adding it, you still having the error, trying to update the gradle plugin in your gradle-wrapper.properties to 4.5 version:

如果添加它,您仍然有错误,尝试将gradle-wrapper.properties中的gradle插件更新为4.5版本:

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

and resync the project.

并重新同步项目。

#3


0  

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.

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

#1


19  

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.0'

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.1'

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

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

Just to add, also you need to add the google() repo in the top level gradle file, as specified in the firebase docs:

只需添加,您还需要在*gradle文件中添加google()repo,如firebase文档中所指定:

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

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

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

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

#2


0  

Since May 23, 2018 update, when you're using a firebase dependency, you must include the firebase-core dependency, too.

自2018年5月23日更新以来,当您使用firebase依赖项时,您还必须包含firebase-core依赖项。

If adding it, you still having the error, trying to update the gradle plugin in your gradle-wrapper.properties to 4.5 version:

如果添加它,您仍然有错误,尝试将gradle-wrapper.properties中的gradle插件更新为4.5版本:

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

and resync the project.

并重新同步项目。

#3


0  

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.

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