Ошибка: при добавлении зависимости Firebase Storage в Android Studio Project? - PullRequest
0 голосов
/ 29 июня 2018

Я создал проект Firestore в Android Studio. В котором у меня реализована авторизация Firebase и она работает абсолютно нормально. Я могу отправить документы в базу данных Firestore.

Но сейчас я пытаюсь добавить функциональность, с помощью которой я могу хранить мультимедиа / изображения в Firebase Storage, но когда я добавляю эту зависимость в файл build.gradle приложения, я получаю эту ошибку:

Зависимость добавлена:

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

К вашему сведению, в моем проекте у меня уже есть такая конфигурация:

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

И

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

Я не могу найти, что происходит, когда я просто добавляю зависимость firebase-storage в мой проект Android.

Вот файл уровня моего приложения build.gradle:

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:

// 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
}

Ответы [ 5 ]

0 голосов
/ 01 июля 2018

Я смог заставить его работать, ребята. Вы можете просто сравнить мои новые файлы Gradle. Проблема заключалась в конфликте библиотек служб Google и версии Gradle. Итак, я создал новый проект и просто добавил зависимости, как это, и это сработало.

Итак, я удалил это из app / build.gradle:

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

И удалил это из модуля / build.gradle:

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

и обновленная версия Gradle в модуле / build.gradle:

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

Новые файлы build.gradle выглядят следующим образом.

модуль / 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
}

приложение / 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'
0 голосов
/ 29 июня 2018

Также вы можете использовать настройку Firebase Assitant

enter image description here

0 голосов
/ 29 июня 2018

Вы должны добавить dependencies {classpath 'com.google.gms:google-services:4.0.1'} и repositories { google()} в корневой файл build.gradle. Вы добавили это? Более того, предоставьте весь файл build.gradle, чтобы понять вашу проблему.

0 голосов
/ 29 июня 2018

Обновите следующее:

 implementation 'com.google.firebase:firebase-firestore:16.0.0'
 implementation 'com.google.firebase:firebase-auth:15.1.0'

в это:

 implementation 'com.google.firebase:firebase-firestore:17.0.2'
 implementation 'com.google.firebase:firebase-auth:16.0.2'

Проверьте здесь для получения дополнительной информации:

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

0 голосов
/ 29 июня 2018

Вы добавили их в свой корневой файл уровня?

buildscript {

    dependencies {

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

allprojects {

    repositories {

        google() 
    }
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...