1

I am trying to create a connection library for use in all of our Android applications. They will all use Firebase, but only to store the FCM Token for the devices, and to receive messages from Firebase console. Mainly the apps will connect to our backend server, which will make calls to a Firebase Functions url to get a custom login token, that is sent back to the library/device with some other data from our server. The library will then login to Firebase using the custom token it gets from our server, and then get the FCM token and save it to the database under that users uuid. The problem I am having is, when I try to add Firebase with Android Studio I am getting the message

"Could not find the Android Application Module. Only Android Application Modules can be connected to Firebase online projects..."

In order to make this a library I have followed the guidelines https://developer.android.com/studio/projects/android-library <-there. It says to remove the applicationId from the build.gradle file and to change the

apply plugin: 'com.android.application'

to

apply plugin: 'com.android.library'

However as soon as you do that, you can no longer login to Firebase with Android Studio. I am trying to avoid having to rewrite the same connection/login/FCM logic on every Android app we have. I thought a library would be the smartest way to handle this, but it looks like Firebase doesn't allow use in a library. Is there any way to accomplish this, or am I going to have to just copy/paste the same connection logic to all of our apps? That seems like a terrible idea. Thank you.

Neglected Sanity
  • 1,770
  • 6
  • 23
  • 46
  • Have you gotten any result? – Ehsan Mashhadi Sep 24 '18 at 12:17
  • 1
    @EhsanMashhadi unfortunately no. It looks like it is a limitation within the firebase library. You have to be in an android application, so there is no way (at least right now) to use firebase in a library module. – Neglected Sanity Sep 25 '18 at 00:43
  • @NeglectedSanity, please see https://stackoverflow.com/questions/53876071/how-to-add-a-maven-manifest-to-an-aar-which-specifies-dependencies. Am I chasing the same issue? (Note that I could get Firebase to work in a library if I used "transitive=true" in the dependency declaration.) Thanks. – ScottyB Feb 05 '19 at 03:16

0 Answers0