Firebase Analytics don't seem to be sending any data

Hi all,

I’ve set up the firebase analytics plugin just like instructed in this demo: https://github.com/scottrules44/firebaseAnalytics-demo

I cannot seem to get any data sent to Firebase.

I tried building a normal Android Studio app with Java to see if Firebase would receive data and it did, but the Corona app on my phone didn’t send any data to Firebase.

I also set up Charles proxy to intercept my phone’s traffic, it has no data being sent out when “logEvent Hello, World” is pressed. I made a second button that opens a news URL and Charles proxy detected packets being sent.

I am using Windows 10 and Corona Simulator 2018.3326 (2018.6.25). My phone is Sugar C12 with Android 8.1.0. Also tested on an iPad.

Don’t really know what else to try from here.

Any help would be greatly appreciated!

I tested this out recently and it worked. Hmmm let me see if I find the demo app I built. Please look at any errors in the logs for Firebase. I know that it first it didn’t work for me just following the instructions but looking at the error there was a very clear description of the problem.

But anyway when I get a chance today. I’ll look for the app I built with Firebase analytics to see how I did it.

It is not working for me either. I get this error in the logs:

AppMeasurementService not registered/enabled

And I found this stack overflow:

https://stackoverflow.com/questions/39480272/firebase-analytics-appmeasurement-not-enabled

But the same app a few versions ago is recording events successfully. So I don’t know what happened.

I just patched this please read docs about adding google Id to build settings

Hey Scott, I posted on the Corona Slack channel but not sure if you would have seen that. Since the last update to the Firebase Analytics plugin, my Android apps crash on startup with the following error:

Corona : \> Class.forName: plugin.firebaseAnalytics.LuaLoader Corona : \< Class.forName: plugin.firebaseAnalytics.LuaLoader Corona : Loading via reflection: plugin.firebaseAnalytics.LuaLoader Corona : ERROR: Runtime error Corona : java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp; Corona : Java Stack Trace: Corona : plugin.firebaseAnalytics.LuaLoader$init.invoke(LuaLoader.java:160)

I tried including plugin.firebase along with plugin.firebaseAnalytics to see if that made a difference, but still saw the same error.

Please post your build.setting

also, make sure you have google-services.json in app root folder

Sure, here are the build.settings (I’ve obfuscated the google_app_id but in my actual file it’s correct):

settings = { orientation = { default = "portrait", supported = { "portrait", "portraitUpsideDown", "landscapeLeft", "landscapeRight"} }, plugins = { ["plugin.advertisingId"] = { publisherId = "com.coronalabs" }, ["plugin.openssl"] = { publisherId = "com.coronalabs", supportedPlatforms ={ iphone=true, android=true,} }, ["plugin.impack"] = { publisherId = "com.xibalbastudios" ,}, ["plugin.Bytemap"] = { publisherId = "com.xibalbastudios",}, ["plugin.AssetReader"] = { publisherId = "com.xibalbastudios",}, ["plugin.MemoryBlob"] = { publisherId = "com.xibalbastudios",}, ["plugin.applovin"] = { publisherId = "com.coronalabs"}, ["plugin.gameanalytics\_v2"] = { publisherId = "com.gameanalytics", supportedPlatforms = { iphone=true, android=true } }, ["plugin.firebase"] = { publisherId = "tech.scotth", supportedPlatforms ={ iphone=true, android=true,} }, ["plugin.firebaseAnalytics"] = { publisherId = "tech.scotth", supportedPlatforms ={ iphone=true, android=true,} }, }, android = { useGoogleServicesJson = true, strings = { ["google\_app\_id"]= "1:123456789012:android:1234567891234567" }, usesPermissions = { "android.permission.INTERNET", "android.permission.WRITE\_EXTERNAL\_STORAGE", "android.permission.ACCESS\_NETWORK\_STATE", }, }, iphone = { xcassets = "Images.xcassets", plist = { NSAppTransportSecurity = { NSAllowsArbitraryLoads=true },--needed for appodeal FacebookAppID = "", UIApplicationExitsOnSuspend = false, UIPrerenderedIcon = true, UIStatusBarHidden = true, --UIBackgroundModes = {"remote-notification"}, UIAppFonts = { }, UILaunchStoryboardName = "LaunchScreen", CFBundleIconFiles = {}, } }, }

The google-services.json file was already in my project’s root directory as well, and has been for some time. The plugin has been working in the app since April 2018, it only started crashing last week.

Which version of corona are you using?

Currently using build 3476.

I have exactly the same problem with the Google signin plugin - recently hangs on load.  Has something changed in Corona to cause this?

“GLThread 391” prio=5 tid=11 Waiting | group=“main” sCount=1 dsCount=0 flags=1 obj=0x12f081c8 self=0xa87c4e00 | sysTid=8751 nice=0 cgrp=default sched=0/0 handle=0x98784970 | state=S schedstat=( 8001926435 3929763813 6512 ) utm=737 stm=62 core=5 HZ=100 | stack=0x98682000-0x98684000 stackSize=1038KB | held mutexes=

 

at java.lang.Object.wait (Native method)

  • waiting on <0x013f6df1> (a java.lang.Object)

 

at java.lang.Thread.parkFor$ (Thread.java:2137)

  • locked <0x013f6df1> (a java.lang.Object)

 

at sun.misc.Unsafe.park (Unsafe.java:358)

 

at java.util.concurrent.locks.LockSupport.park (LockSupport.java:190)

 

at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await (AbstractQueuedSynchronizer.java:2059)

 

at com.google.android.gms.common.api.internal.zzbd.blockingConnect (unavailable)

 

at com.google.android.gms.common.api.internal.zzav.blockingConnect (unavailable)

 

at plugin.googleSignIn.LuaLoader$silentSignIn.invoke (LuaLoader.java:390)

 

at com.ansca.corona.JavaToNativeShim.nativeRender (Native method)

 

at com.ansca.corona.JavaToNativeShim.render (JavaToNativeShim.java:220)

 

at com.ansca.corona.Controller.updateRuntimeState (Controller.java:382)

  • locked <0x0dec4f75> (a com.ansca.corona.Controller)

 

at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame (CoronaGLSurfaceView.java:450)

 

at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun (GLSurfaceView.java:1625)

 

at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run (GLSurfaceView.java:1380)

I can confirm that firebase plugin stopped working. I have tried 3 different versions of Corona.

java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/FirebaseApp; at plugin.firebaseAnalytics.LuaLoader$init$1.run(LuaLoader.java:166) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7116) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:925) Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.firebase.FirebaseApp" on ...

Any luck with firebase analytics.

I am also facing the similar issue, the plugin was working perfect before and now it suddenly stopped after i update corona to latest version 3480.

Here is the detailed log. https://pastebin.com/UbVtY0ME

 

This is the code i have used in the main:

local firebaseAnalytics = require “plugin.firebaseAnalytics”

firebaseAnalytics.init()

firebaseAnalytics.logEvent(“Game started”, {content_type = “Main”, item_id= “Running Fast”})

 

Note*(firebaseAnalytics.logEvent is causing this crash, it says Attempt to invoke virtual method ‘Void com.google.firebase.analytics.firebaseAnalytics.logEvent(java.lang.string, java.os.bundle)’ on a null object reference)

i tried to check firebaseAnalytics after init call and its a perfect table value.

 

 

 

This is my plugin call in Build

[“plugin.firebaseAnalytics”] = { publisherId = “tech.scotth”, },

 

this is inside Android table in build

[“google_app_id”]= “1:XXXXXX:android:XXXXXXX” I have written XXXXX for my Id to keep it safe

},

useGoogleServicesJson = true,

Please check this asap, i need to push updates very urgent. Thanks in Advance

Sahil, did you solve this ?

what is the google_app_id you are using ? what id is it exactly ?

No, It was not solved that time then i left this plugin and use fb analytics instead. That worked perfectly for me. Not a great details on country for installs but atleast helping me with data.

@Scott, did you manage to look any further into why the Firebase Analytics plugin has stopped working? After leaving it for a couple of months I’ve tried again, and now get a different error:

java.lang.NullPointerException: Attempt to invoke virtual method 'void.com.google.firebase.analytics.FirebaseAnalytics.logEvent(java.lang.String, android.os.Bundle)' on a null object reference

I am just look at this now

Hello Alan, did you check it with Corona 64 bit version or still testing on 32 bit. I suggest may be try with 2019.3509 once.

I just tried building for my android 8.0 device using the sample on docs and everything is working fine using Corona 2019.3512

Can someone email me a project where they are getting this crash

@Scott, my Android 8.1 device works with your Firebase demo project now using Corona 2019.3512. Though some of our other plugins don’t work with the new 64-bit build.

@Scott - I think I’ve partly worked out what is happening. My app has some logEvent calls when the app starts up, just after I call firebaseAnalytics.init().  

I think what’s happening is that my logEvent() call is being called before Firebase has finished initialising. The init function doesn’t have a callback so there’s no way of knowing when it’s finished. 

As a test I tried blocking my logEvent calls with a “hasInitialised” call, and then I set that to true after 2s. The error went away.

Is there any way that an init callback could be added so that we know when the library has finished initialising? Using timer.performWithDelay isn’t a reliable method, because it assumes that the plugin did initialise properly. If the init fails for some reason, the next time logEvent is called the app will crash regardless of how long a delay we allow.