【问题标题】:I tried to connect my Android app to google firebase but it displays an error我试图将我的 Android 应用程序连接到 google firebase,但它显示错误
【发布时间】:2020-06-05 16:38:00
【问题描述】:

我尝试将我的应用程序连接到 google firebase,我按照程序在 Gradle 和 JSON 文件中实现。之后,我尝试运行我的应用程序并显示以下错误消息:

这是我的 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.5.3'
            classpath 'com.google.gms:google-services:4.3.3'
            // 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

这是我的另一个 Gradle 模块:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"
    defaultConfig {
        applicationId "com.example.ius"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.0.0'
    implementation 'androidx.navigation:navigation-ui:2.0.0'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    implementation 'com.google.firebase:firebase-analytics:17.2.2'
    implementation 'com.google.firebase:firebase-auth:19.2.0'
    testImplementation 'junit:junit:4.12'
    implementation 'com.android.volley:volley:1.1.0'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}

如果你能帮助我,那对我来说就意味着整个世界。在此先感谢:D

【问题讨论】:

  • 您好,欢迎来到堆栈溢出,不要将错误消息作为图像发布,而是仅以文本格式将它们粘贴到问题中

标签: android database firebase android-studio gradle


【解决方案1】:

将您的 minSdkVersion 15 更改为 minSdkVersion 16

正如Docs 所说的那样

确保您的应用满足以下要求: 针对 API 级别 16(Jelly Bean)或更高版本

【讨论】:

  • 如何更改?你能指导我吗
  • 在你的 Gradle 模块文件中将 minSdkVersion 15 更改为 minSdkVersion 16 Image Link
  • 非常感谢,你救了我
  • @user738462 很高兴为您提供帮助:)
【解决方案2】:

您的某些库具有 minSdk 16。因此您必须将 minSdkVersion 更改为 16 或更改与 sdk 15 兼容的库。

在你的 build.gradle(Module 级别)

改变 minSdkVersion 15 转至minSdkVersion 16defaultConfig

PS。为什么你使用 minSDk 是 16,我认为使用 21 还可以。

【讨论】:

  • 如何更改?你能指导我吗
  • 请再次检查我的答案。
【解决方案3】:

在 defaultConfig 中将 minSdkVersion 从 15 更改为 16 可以解决问题...

【讨论】:

    【解决方案4】:

    减少版本库

    实现 'com.google.firebase:firebase-auth:16.0.5'

    【讨论】:

    • 删除所有firebase依赖并通过在Android studio中选择Assistent来添加firebase
    猜你喜欢
    • 2021-11-10
    • 1970-01-01
    • 1970-01-01
    • 2021-08-28
    • 2023-01-04
    • 1970-01-01
    • 2021-03-09
    • 1970-01-01
    • 2021-08-19
    相关资源
    最近更新 更多