简体   繁体   English

在动态功能模块中使用 Firebase 库

[英]Using Firebase Libraries in a Dynamic Feature Module

I'm trying to use FirebaseAuth in a dynamic feature module but I'm getting a:我正在尝试在动态功能模块中使用 FirebaseAuth,但我得到了:

java.lang.AbstractMethodError: abstract method "com.google.android.gms.common.api.Api$Client com.google.android.gms.common.api.Api$AbstractClientBuilder.buildClient(android.content.Context, android.os.Looper, com.google.android.gms.common.internal.ClientSettings, java.lang.Object, com.google.android.gms.common.api.GoogleApiClient$ConnectionCallbacks, com.google.android.gms.common.api.GoogleApiClient$OnConnectionFailedListener)"
        at com.google.android.gms.common.api.GoogleApi.zaa(Unknown Source:93)
        at com.google.android.gms.common.api.internal.GoogleApiManager$zaa.<init>(Unknown Source:7)
        at com.google.android.gms.common.api.internal.GoogleApiManager.zab(Unknown Source:43)
        at com.google.android.gms.common.api.internal.GoogleApiManager.handleMessage(Unknown Source:173)
        at android.os.Handler.dispatchMessage(Handler.java:103)
        at com.google.android.gms.internal.base.zap.dispatchMessage(Unknown Source:8)
        at android.os.Looper.loop(Looper.java:214)
        at android.os.HandlerThread.run(HandlerThread.java:67)

I'm using the latest versions and I tried playing around with lower versions but no luck.我正在使用最新版本,我尝试使用较低版本但没有运气。

project build.gradle.kts:项目 build.gradle.kts:

buildscript {
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath("com.android.tools.build:gradle:4.0.0")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72")
        classpath("com.google.gms:google-services:4.3.3")
        classpath("com.google.firebase:firebase-crashlytics-gradle:2.1.1")
    }
}

app build.gradle.kts:应用程序 build.gradle.kts:

plugins {
    id("com.android.application")
    id("kotlin-android")
    id("com.google.gms.google-services")
    id("com.google.firebase.crashlytics")
}

android {
    ...

    dynamicFeatures = mutableSetOf(":android:auth")
}

dependencies {
    implementation(AndroidDependencies.Core.FIREBASE_ANALYTICS) // 17.4.2
    implementation(AndroidDependencies.Core.FIREBASE_CRASHLYTICS) // 17.0.0
}

auth build.gradle.kts:授权 build.gradle.kts:

plugins {
    id("com.android.dynamic-feature")
    id("kotlin-android")
}

...

dependencies {
    implementation(project(":android:app"))
    implementation(AndroidDependencies.Core.FIREBASE_AUTH) // 19.3.1
}

Has anyone else encountered this?有人遇到过这种情况么? Or am I missing something here?或者我在这里错过了什么?

As described here :如此所述:

To enable support for dynamic feature modules, add the following dependency to your base module's build.gradle file:要启用对动态功能模块的支持,请将以下依赖项添加到基本模块的 build.gradle 文件中:

dependencies {
    implementation 'com.google.firebase:firebase-dynamic-module-support:16.0.0-beta01'
}

I suppose, it's meant that you have to put this line in app\build.gradle file.我想,这意味着您必须将此行放在 app\build.gradle 文件中。 And other Firebase dependencies put to feature modules.和其他 Firebase 依赖项放在功能模块中。

Well, if someone comes across this, I solved it by adding the dependency both on app and auth好吧,如果有人遇到这个问题,我通过添加对appauth的依赖来解决它

app:应用程序:

dependencies {
    implementation(AndroidDependencies.Core.FIREBASE_ANALYTICS)
    implementation(AndroidDependencies.Core.FIREBASE_CRASHLYTICS)
    implementation(AndroidDependencies.Core.FIREBASE_AUTH)
}

auth:授权:

dependencies {
    implementation(project(":android:app"))
    implementation(AndroidDependencies.Core.FIREBASE_AUTH)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM