首页 > 解决方案 > 无法解决:firebase-auth-15.0.0。火力基地错误

问题描述

我正在尝试将 firebase 连接到我的应用程序。按“向您的应用程序添加 firebase 身份验证”后,我收到以下错误:“无法解决:firebase-auth-15.0.0”这导致我在 build.gradle(module:app) 中的依赖项。错误:

implementation 'com.android.support:appcompat-v7:28.0.0'

有关错误的详细信息:

所有 com.android.support 库必须使用完全相同的版本规范(混合版本可能导致运行时崩溃)。找到版本 28.0.0、26.1.0。例子包括 com.android.support:animated-vector-drawable:28.0.0 和 com.android.support:support-media-compat:26.1.0 less... (Ctrl+F1) 有一些库的组合,或者不兼容或可能导致错误的工具和库。一种这样的不兼容性是使用不是最新版本的 Android 支持库版本(或者特别是低于您的 targetSdkVersion 的版本)进行编译。问题 ID:GradleCompatible

我的整个依赖项:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:28.0.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.3'
    implementation 'com.android.support:design:28.0.0'
    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-auth:16.0.1:15.0.0'
} 

标签: androidfirebase

解决方案


在您的根级 build.gradle 中:

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

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

在您的模块 build.gradle 中:

apply plugin: 'com.android.application'

android {
    // ...
}

dependencies {
    // ...
    implementation 'com.google.firebase:firebase-core:16.0.6'
    implementation 'com.google.firebase:firebase-auth:16.0.5'

    // Getting a "Could not find" error? Make sure you have
    // added the Google maven respository to your root build.gradle
}

// ADD THIS AT THE BOTTOM
apply plugin: 'com.google.gms.google-services'

推荐阅读