Status Update
Comments
bo...@google.com <bo...@google.com>
aa...@google.com <aa...@google.com> #2
vk...@google.com <vk...@google.com> #3
In order for firebase to work in dynamic modules you have to follow additional setup instructions:
That said, can you clarify how you're adding the auth/firebase-performance dependency to the module? are you using the firebase plugin or are you manually adding the dependency to your build file?
mk...@opera.com <mk...@opera.com> #4
implementation 'com.google.firebase:firebase-dynamic-module-support:16.0.0-beta01'
doesn't solve the issue.
There is something wrong how the Firebase components are merged in the final apk. Looks like the components defined in feature module overwrites anything defined in base module making the ComponentDiscovery to fail.
mk...@opera.com <mk...@opera.com> #5
So the problem appears when you have different firebase modules used in base module and feature module. Given the exemplary project I shared, when building from Android Studio, no matter if I use "Default APK" or "APK from AppBundle" in the deployment configuration it fails to discover firebase components declared in base module. I don't understand why the following code
packageManager.manager.getServiceInfo(ComponentName(ctx, ComponentDiscoveryService::class.java), PackageManager.GET_META_DATA).metaData
returns only component registrars from dynamic feature module and not the ones from base module despite the fact that base.apk pulled from device have all of them declared in Manifest.
Doing
<service android:name="com.google.firebase.components.ComponentDiscoveryService" tools:node="remove" />
helps but not sure it will let the module be properly initialized after installing dynamic feature module.
Edit:
I dig even more I found out that there are actually 2 ComponentDiscoveryService being found when calling
packagemanager.getPackageInfo("packageid", PackageManager.GET_SERVICE).services
One from base module and one from dynamic feature module.
So I assume the code of firebase service discovery - pasted below - gets the service info from dynamic feature module instead of the one from the base module which obviously is missing some entries.
private Bundle getMetadata(Context context) {
try {
PackageManager manager = context.getPackageManager();
if (manager == null) {
Log.w(TAG, "Context has no PackageManager.");
return null;
}
ServiceInfo info =
manager.getServiceInfo(
new ComponentName(context, discoveryService), PackageManager.GET_META_DATA);
if (info == null) {
Log.w(TAG, discoveryService + " has no service info.");
return null;
}
return info.metaData;
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, "Application info not found.");
return null;
}
}
mk...@opera.com <mk...@opera.com> #6
Is there any update on this one?
Description
STEPS TO REPRODUCE:
1. Create an empty project and add any firebase dependency to it. i.e. firebase performance
2. Add dynamic feature module to the project and define another firebase dependency there i.e. auth
3. Anywhere in the app call FirebasePerformance.getInstance()
3. Launch the app from Android Studio (ensure dynamic feature module is checked in target configuration)
4. Observer the FirebasePerformance.getInstance() returns null !
Looking at the Firebase code seems that the ComponentDiscovery service is only returning the firebase module defined in dynamic feature module.
Example project attached, need just a google-play-services.json file.
Studio Build:
Version of Gradle Plugin: 7.1.1
Version of Gradle: 7.2
Version of Java: 11
OS: Mac OS