Android FirebaseUI resources problem


I’m trying to create a game with firebase google and facebook login. I know that exists a way how to use firebase with unity, but I don’t want to create both login methods separately, when something like FirebaseUI exists.

So I’ve created android plugin with FirebaseUI authentication. I tested it in new android project and everything works fine. But when I use my plugin in unity, I have to add own gradle (mainTemplate.gradle) with dependencies for firebaseUI.

Problem is that there is a default value in firebase auth library and when the game is built, values from my library (default_web_client_id etc.) is overwritten by default value.

Almost after week I found a solution, but I hope there is another way.

My solution:
Build android library with firebase, copy library (.aar) to Assets/Plugins, export unity projekt with this library to Idea, then copy whole values.xml (that is created from google-services.json) and facebook appId to res folder in exported project. (then build from Idea)

It’s working, but by this method, I have default_web_client_id 3 times in projekt (1x from my library, 1x from FirebaseUI dependency and 1x from copied values.xml, that overrides them). It’s not a problem, but I think that it’s not necessary.

Is there any more elegant way how to work with android libraries?


mainTemplate (dep part): 135259-maintemplatedep.png


after some more experiments I found that it depends on implementation order, so I moved **DEPS** up and now its working.

So the solution is easy:

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
	def room_version = "1.1.1"

    implementation "$room_version"
    annotationProcessor "$room_version"
    implementation ''
    implementation ''
    implementation ''

    implementation "android.arch.lifecycle:extensions:1.1.1"
    implementation "android.arch.lifecycle:viewmodel:1.1.1"
    annotationProcessor "android.arch.lifecycle:compiler:1.1.1"

    implementation ''
    implementation 'com.firebaseui:firebase-ui-auth:4.3.1'
    implementation ''

Hope that this helps somebody.