androidfirebasegoogle-play-servicesdynamic-feature-moduledynamic-feature

Using Firebase Libraries in a Dynamic Feature Module


I'm trying to use FirebaseAuth in a dynamic feature module but I'm getting a:

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:

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:

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:

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?


Solution

  • As described here:

    To enable support for dynamic feature modules, add the following dependency to your base module's build.gradle file:

    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. And other Firebase dependencies put to feature modules.