android - 如何在 Android 中使用 Firebase?

标签 android firebase android-gradle-plugin google-play-services

将 Firebase 添加到我的应用程序后,我对 gradle 问题很生气, 我收到错误: 找不到 com.google.android.gms.internal.zzbgl 的类文件

我正在使用 android location 和 url stringRequest,直到那时它运行良好,然后我将 Firebase 添加到 gradle(我已经在 Firebase 网站上注册并添加了生成的 google-services.json)

我检查了很多没有帮助的答案,我已经将 gradle 更新到 3.4.2 仍然无法正常工作

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    buildToolsVersion "28.0.3"
    defaultConfig {
        applicationId "com.example.mapwithmarker"
        minSdkVersion 22
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        resValue "string", "google_maps_key", (project.findProperty("GOOGLE_MAPS_API_KEY") ?: "")
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'com.android.support:appcompat-v7:26.1.0'
    implementation 'com.google.android.gms:play-services:12.0.1'
    implementation 'com.mcxiaoke.volley:library:1.0.19'
    implementation 'com.google.firebase:firebase-core:17.0.1'
    testImplementation 'junit:junit:4.12'
}

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


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

buildscript {
    repositories {
        jcenter()
        google()
        //maven {
         //   url "https://maven.google.com"
        //}
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.4.2'
        classpath 'com.google.gms:google-services:4.2.0'
        // 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
}

有什么帮助吗?

最佳答案

official docs 所述,

“不要使用组合播放服务目标。它引入了数十个库,使您的应用程序膨胀。相反,仅指定您的应用使用的特定 Google Play 服务 API。”

你不应该使用组合播放服务库。而是尝试使用您需要的特定库并尝试将特定库更新到 17.0.0

关于android - 如何在 Android 中使用 Firebase?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57043904/

相关文章:

java - 从任何网络Flutter访问HTTP服务器

android - Android 集成/功能测试的外部化配置

firebase - flutter 包 flutter_stripe 是否需要后端来处理付款?

java - Android Studio上的Gradle同步失败

android - 类名与路径不匹配?

android - 分配的内存不断增加

Android模拟器-dns-server使用

android - 我可以将可缩放像素用于布局尺寸吗?

firebase - 在 firebase 函数部署上对 google cloud secret 的权限被拒绝

firebase - 如何防止 Firebase Firestore 模拟器在退出时清除数据库?