错误:将Firebase Storage依赖项添加到Android Studio Project中? [英] Error: In adding Firebase Storage dependency to Android Studio Project?

查看:60
本文介绍了错误:将Firebase Storage依赖项添加到Android Studio Project中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Android Studio中创建了一个Firestore项目.我在其中实施了Firebase授权,并且工作正常.我可以将文档推送到Firestore数据库.

I have created a Firestore Project in Android Studio. In which I have Firebase Authorization implemented and that is working absolutely fine. I am able to push documents to Firestore Database.

但是现在,我正在尝试添加一些功能,通过这些功能可以将媒体/图像存储到Firebase Storage中,但是当我将此依赖项添加到应用的build.gradle文件中时,出现此错误:

But now, I am trying to add functionality using which I can store media/images to Firebase Storage but when I am adding this dependency to app's build.gradle file, I am getting this error:

已添加依赖项:

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

这是我得到的错误:

Could not find firebase-common.jar (com.google.firebase:firebase-common:16.0.0).
Searched in the following locations:https://jcenter.bintray.com/com/google/firebase/firebase-common/16.0.0/firebase-common-16.0.0.jar

仅供参考,在我的项目中,我已经有这种配置:

FYI, In my project I already have this kind of configuration:

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

还有

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

当我仅将firebase-storage依赖项添加到我的Android项目中时,我找不到问题所在.

I can not find what is going wrong when I just add firebase-storage dependency to my Android project.

这是我的应用程序级别的build.gradle文件:

Here is my app level build.gradle file:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion '27.0.3'

    defaultConfig {
        applicationId "com.firebase.example"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
}

dependencies {
    implementation 'com.google.firebase:firebase-firestore:16.0.0'
    implementation 'com.google.firebase:firebase-auth:15.1.0'
    implementation 'com.google.firebase:firebase-storage:16.0.1'

    implementation 'com.google.android.gms:play-services-auth:15.0.1'

    implementation fileTree(dir: 'libs', include: ['*.jar'])
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.support:appcompat-v7:23.2.1'
    implementation 'com.android.support:design:23.2.1'
    implementation 'com.android.support:recyclerview-v7:23.2.1'
}
apply plugin: 'com.google.gms.google-services'

这是我的模块级别的build.gradle文件:

Here is my module level build.gradle file:

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

buildscript {
    repositories {
        jcenter()
        google()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:4.0.1' // google-services plugin
        classpath 'com.google.android.gms:play-services-base:15.0.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

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

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

推荐答案

我能够使它正常工作.您可以简单地比较我的新gradle文件.问题是Google服务库和Gradle版本冲突.因此,我创建了一个新项目,并像这样再次添加了依赖项,它就起作用了.

I was able to make it work guys. You can simply compare my new gradle files. The issue was conflicting google services libraries and gradle version. So, I created new project and just added dependencies again like this and it worked.

因此,我从app/build.gradle中删除了它:

implementation 'com.google.android.gms:play-services-auth:15.0.1'

然后,将其从module/build.gradle中删除:

classpath 'com.google.android.gms:play-services-base:15.0.1'

,并在module/build.gradle中更新了gradle版本:

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

新的build.gradle文件如下所示.

New build.gradle files look like this.

module/build.gradle:

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

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.3'
        classpath 'com.google.gms:google-services:4.0.1' // google-services plugin

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

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

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

app/build.gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "master.firebasesetup"
        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:support-v4:27.1.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.firebase:firebase-firestore:17.0.2'
    implementation 'com.google.firebase:firebase-auth:16.0.2'
    implementation 'com.google.firebase:firebase-storage:16.0.1'
    implementation 'com.google.firebase:firebase-core:16.0.1'
}
apply plugin: 'com.google.gms.google-services'

这篇关于错误:将Firebase Storage依赖项添加到Android Studio Project中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆