问题
I have a Library Project consisting of a single Activity with various fragments and helper classes.
I have FirebaseAnalytics put inside this library project, put in its own helper class. The instance in that helper class was retrieved using the code:
private val firebaseAnalytics = FirebaseAnalytics.getInstance(LibInterface.getInstance().srcApp)
As can be inferred from the code, I'm using the source application's Application
instance to get the instanceof the FirebaseAnalytics
used in the library project.
This source application also uses its own FirebaseAnalytics
instance:
mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
I'm taking a guess that both instances of FirebaseAnalytics
would be the exact same, and that they would both be sending tracked events into the App's Firebase project.
Is it possible to send the events tracked in the library project into a separate Firebase project by getting the FirebaseAnalytics
instance using the context of the sole Activity inside the Library project, and do I need a library-level google-services.json
for that?
回答1:
It is not possible. Analytics works per-app, not per-library. There is currently no way for a library to redirect analytics information to a different project than the one that was used as the default for the app. This is important to make sure that each app owners understands the activity of the app in its entirety.
来源:https://stackoverflow.com/questions/52694971/is-it-possible-for-the-firebaseanalytics-instance-in-my-library-project-to-send