Adding firebase to Enterprise project

Hello!

So I’m trying to add firebase to the Android studio project for my plugin. However, I’m having some issues with version compatibility (Its giving me an error about multidexing).

Also, there are some dependencies that I need to put is the app build.gradle and I’m not exactly sure how to handle them once I export this to a plugin.

Following the guides from here:

https://firebase.google.com/docs/android/setup

https://firebase.google.com/docs/cloud-messaging/android/client

In app build.gradle I need to add this:

buildscript {     // ...     dependencies {         // ...         classpath 'com.google.gms:google-services:3.0.0'     } }

and this:

apply plugin: 'com.google.gms.google-services'

And then I’m adding the messaging library, so I’m putting this in my plugin build.gradle:

dependencies {      compile 'com.google.firebase:firebase-messaging:10.2.0' }

However, when I compile, I get this error:

Error:Execution failed for task ‘:app:transformClassesWithDexForRelease’.

> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzaac$zza;

And when I look at the pre-dexed filed, in the intermediaries folder, I see 10.0.1 version and 10.2.0 version. Does Corona include some libraries automatically? If not what can be the folder. Also, how do I handle compiling these libraries into a plugin? 

Thank you!

Our dependency system relies on Google Play Services 9.6.1.

You should be able to build your Enterprise project if you change the Firebase version from 10.2.0 to 9.6.1

If you plan on releasing a plugin in the Corona Marketplace, there are a few things to be aware of when distributing the plugin. First of all classpath ‘com.google.gms:google-services:3.0.0’ and apply plugin: ‘com.google.gms.google-services’ are not used as the Corona SDK build system isn’t Gradle based. 

That particular Gradle plugin simply parses the Firebase JSON file and creates resource strings that are included in the final APK.

We are working on some Firebase-related plugins and will introduce additional dependency plugins for Firebase that you’ll be able to use in your Corona SDK plugin projects once they are ready.

If your project is Enterprise only using Android Studio, then you can continue using the setup according to the Firebase documentation.

Thanks for your reply!

Do you happen to know if there are alternatives to parsing the Firebase JSON file without using the ‘com.google.gms.google-services’ plugin?

Not that I know of, however the entries can be manually set up by entering the string resources in build.settings.
These are the string resources that the Gradle plugin generates. The values can be found in the JSON file.

android = { permissions = {}, usesPermissions = {}, strings = { default\_web\_client\_id = "xxxxxxx.apps.googleusercontent.com", firebase\_database\_url = "https://fir-cloud-messaging-xxxx.firebaseio.com", gcm\_defaultSenderId = "xxxx", google\_api\_key = "xxxx", google\_app\_id = "x:xxxx:android:xxxx", google\_crash\_reporting\_api\_key = "xxxx", google\_storage\_bucket = "fir-cloud-messaging-xxxx.appspot.com" } },

After entering the string resources you don’t need to include the JSON file in the Corona project as it’s not used.

Perfect, got that working.
 
One last thing. com.ansca.corona.notifications.GoogleCloudMessagingBroadcastReceiver seems to be intercepting the firebase notifications. However, since I don’t have control of the data in the notifications, I cannot set the data that indicates the title, audio, etc. Is there a way to disable that behavior? If not, can I somehow override it so that I can customize the notification details after the notification is sent?

Thanks again!

We’re aware of the issue. At the moment the GCM receiver is included in the default Android manifest for Corona which is causing conflicts with Firebase.

We’re working on a fix for this, since it needs to be fixed for the official Firebase Messaging plugin which will be ready soon.

@Deleur Apps

Is this a plugin that you intend to release to the public, or just one for your own private use? If it’s for public release, is it also going to include the analytics which (I believe) is in the Firebase core?

There is a community plugin for Firebase analytics :

https://marketplace.coronalabs.com/plugin/firebase-analytics

Is there a link to an Enterprise plugin? I don’t see one in the docs, but perhaps I’ve overlooked it.

You can ask the developer, Scott Harrison, if he provides Enterprise binaries.

https://marketplace.coronalabs.com/vendor/b9ab8939-5f0f-478a-ae19-b968092bdafb

I open sourced this plugin along time ago,

https://github.com/scottrules44/firebaseAnalytics-source

I really have not changed much in the marketplace version.

If you want the binaries, you need to email me (scottrules44@gmail.com)

Our dependency system relies on Google Play Services 9.6.1.

You should be able to build your Enterprise project if you change the Firebase version from 10.2.0 to 9.6.1

If you plan on releasing a plugin in the Corona Marketplace, there are a few things to be aware of when distributing the plugin. First of all classpath ‘com.google.gms:google-services:3.0.0’ and apply plugin: ‘com.google.gms.google-services’ are not used as the Corona SDK build system isn’t Gradle based. 

That particular Gradle plugin simply parses the Firebase JSON file and creates resource strings that are included in the final APK.

We are working on some Firebase-related plugins and will introduce additional dependency plugins for Firebase that you’ll be able to use in your Corona SDK plugin projects once they are ready.

If your project is Enterprise only using Android Studio, then you can continue using the setup according to the Firebase documentation.

Thanks for your reply!

Do you happen to know if there are alternatives to parsing the Firebase JSON file without using the ‘com.google.gms.google-services’ plugin?

Not that I know of, however the entries can be manually set up by entering the string resources in build.settings.
These are the string resources that the Gradle plugin generates. The values can be found in the JSON file.

android = { permissions = {}, usesPermissions = {}, strings = { default\_web\_client\_id = "xxxxxxx.apps.googleusercontent.com", firebase\_database\_url = "https://fir-cloud-messaging-xxxx.firebaseio.com", gcm\_defaultSenderId = "xxxx", google\_api\_key = "xxxx", google\_app\_id = "x:xxxx:android:xxxx", google\_crash\_reporting\_api\_key = "xxxx", google\_storage\_bucket = "fir-cloud-messaging-xxxx.appspot.com" } },

After entering the string resources you don’t need to include the JSON file in the Corona project as it’s not used.

Perfect, got that working.
 
One last thing. com.ansca.corona.notifications.GoogleCloudMessagingBroadcastReceiver seems to be intercepting the firebase notifications. However, since I don’t have control of the data in the notifications, I cannot set the data that indicates the title, audio, etc. Is there a way to disable that behavior? If not, can I somehow override it so that I can customize the notification details after the notification is sent?

Thanks again!

We’re aware of the issue. At the moment the GCM receiver is included in the default Android manifest for Corona which is causing conflicts with Firebase.

We’re working on a fix for this, since it needs to be fixed for the official Firebase Messaging plugin which will be ready soon.

@Deleur Apps

Is this a plugin that you intend to release to the public, or just one for your own private use? If it’s for public release, is it also going to include the analytics which (I believe) is in the Firebase core?

There is a community plugin for Firebase analytics :

https://marketplace.coronalabs.com/plugin/firebase-analytics

Is there a link to an Enterprise plugin? I don’t see one in the docs, but perhaps I’ve overlooked it.

You can ask the developer, Scott Harrison, if he provides Enterprise binaries.

https://marketplace.coronalabs.com/vendor/b9ab8939-5f0f-478a-ae19-b968092bdafb