We have a lot of library dependencies in our Android project, some of which depend on google services. As such, we use gradle system (custom gradle template in Unity) to handle all dependencies in one place, partially removing duplicated entries using "exclude" mechanics. It also allows us to track different required versions of different plugins
Now we also need to add Firebase Analytics to our Unity game to enable better Google Ads learning to provide better ads traffic quality.
We have followed the "happy path" of integrating Unity plugin and resolving all dependencies using Google Play Services Resolver, which adds a bunch of .jar and .aar files in our project, some of which are clashing with our dependencies from the Gradle system, which results in a failed build for Android due to duplicated library entries (I can post a log here, but it won't help to solve the problem at a higher level).
Thus we have followed the not-so-happy-path of integrating "pure" Android Firebase plugin, which seems to be using only gradle and no manually downloaded .jar or .aar files.
In the process, we have found out that "pure" Android plugin only requires "firebase-core" lib, while Unity plugin also requires "firebase-analytics", "firebase-iid" and "firebase-unity". And while it's possible to include first two options with gradle directly (three if we count "firebase-core"), the last one ("firebase-unity") is stored in a local Unity project folder-based Maven repository as a .scaar file. And we can't just "tie" it through some hardcoded file path because it will be different on every developer machine (mac / windows).
Unity plugin, unlike "pure" Android one, also requires some "app" dependencies on "firebase-common", "firebase-app-unity" and "auto value annotations".
One possible solution would be to manually delete clashing libraries from the plugins folder (those files that Player Services Resolver has downloaded), but it will get in a way of Resolver's work, possibly breaking something in the process
Another one is to manually exclude clashing libraries from Gradle, but it will not be apparent enough as why there are excluded libs in that folder. And if someday we update one of the plugins with "raw" .jar or .aar files, some of them may disappear out of the Plugins folder (Resolver possibly deleting some of them due to not being used anymore), it will lead to runtime crashes, which are much harder to track than simple compilation fails.
My questions are:
- what is an effective solution for integrating Firebase Analytics into an existing project with other Google Services and common libraries dependencies which use Gradle as dependency management tool?
- why does Unity plugin requires so many more dependencies compared to "pure" android project? I can understand about "firebase-unity" lib, but what about 4 others?