Google Firebase Analytics - Messages not received by Firebase

Hello all.

I've been trying to send messages via Dependency Injection to Google Firebase via an Android app. From what I see that information is being sent, but the information never shows up in the DebugView in Firebase Analytics. I went to a separate app just to work on this Firebase Analytics problem, to be sure that I've not added some other extraneous issues. This sample app has a button to enable analytics and buttons to send a Firebase log event or a user property. Neither one is ever sent out, but show up on the log. I'm using a emulator with GPS installed on it.

I've been working with Google for the last month or so to see where the problem is. They say that they see the data coming in, but there is something wrong with it; they cannot quantify what is the issue on with the data that they see. They have just said that they want to see the code. Given that this is not Android Studio and not their Cocoa Pods, they will likely say it's not their problem.

If anyone might have some insight, I'd really love to hear it.

Involved Google Packages:

  • Xamarin.Android.Crashlytics
  • Xamarin.Android.Crashlytics.Answers
  • Xamarin.Android.Crashlytics.Beta
  • Xamarin.Android.Crashlytics.Core
  • Xamarin.Android.Fabric
  • Xamarin.Build.Download (pre release)
  • Xamarin.Firebase.Analytics
  • Xamarin.Firebase.Analytics.Impl

I'll reply to this topic to put the Android DI code.

**I'm including most of the logging detail, just in case something might help determine the problem. Note: I had to remove items from the Application Output to make this fit the character limit.

FYI: I am not going to use the Tag manager, so that's not an issue for me.
Note: I see the GSM trying to cancel 812057698. I think that's a unrelated issue to my code. I've not seen that on prior loggings.

I've turned on the logging via:

adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE

adb logcat -s FA FA-SVC

This is the logcat result:

03-02 14:37:02.834 5211 6218 V FA-SVC : Measurement Phenotype flag(s) updated
03-02 14:38:54.845 6461 6461 I FA : App measurement is starting up, version: 11400
03-02 14:38:54.845 6461 6461 I FA : To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
03-02 14:38:54.848 6461 6461 V FA : Collection enabled
03-02 14:38:54.848 6461 6461 V FA : App package, google app id: com.example.crashtest, 1:75859314137:android:eh18at2sx84fvwxo
03-02 14:38:54.849 6461 6461 I FA : To enable faster debug mode event logging run:
03-02 14:38:54.849 6461 6461 I FA : adb shell setprop debug.firebase.analytics.app com.example.crashtest
03-02 14:38:54.849 6461 6461 D FA : Debug-level message logging enabled
03-02 14:38:54.851 6461 6461 V FA : Cancelling job. JobID: -1962091572
03-02 14:38:54.851 6461 6461 V FA : Registered activity lifecycle callback

> 03-02 14:38:54.920 6461 6461 V FA : onActivityCreated

03-02 14:38:55.261 6461 6496 V FA : Using measurement service
03-02 14:38:55.261 6461 6496 V FA : Connection attempt already in progress
03-02 14:38:55.261 6461 6496 V FA : Activity resumed, time: 395545
03-02 14:38:55.262 6461 6496 I FA : Tag Manager is not found and thus will not be used
03-02 14:38:55.264 6461 6496 D FA : Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-2098017139612028370}]
03-02 14:38:55.287 6461 6496 V FA : Using measurement service
03-02 14:38:55.287 6461 6496 V FA : Connection attempt already in progress
03-02 14:38:55.445 6461 6496 D FA : Connected to remote service
03-02 14:38:55.445 6461 6496 V FA : Processing queued up service tasks: 4
03-02 14:38:55.476 5298 6500 D FA-SVC : Setting user property: first_open_time(_fot), 1551556800000
03-02 14:38:55.478 5298 6500 D FA-SVC : User property set: first_open_time(_fot), 1551556800000
03-02 14:38:55.489 5298 6500 D FA-SVC : Setting user property: first_open_after_install(_fi), 1
03-02 14:38:55.490 5298 6500 D FA-SVC : User property set: first_open_after_install(_fi), 1
03-02 14:38:55.493 5298 6500 V FA-SVC : Logging event: origin=auto,name=first_open(_f),params=Bundle[{firebase_conversion(_c)=1, _r=1, previous_first_open_count(_pfo)=0, system_app(_sys)=0, update_with_analytics(_uwa)=0, system_app_update(_sysu)=0}]
03-02 14:38:55.514 5298 6500 V FA-SVC : Saving event, name, data size: first_open(_f), 71
03-02 14:38:55.514 5298 6500 V FA-SVC : Event recorded: Event{appId='com.example.crashtest', name='first_open(_f)', params=Bundle[{firebase_conversion(_c)=1, firebase_event_origin(_o)=auto, _r=1, previous_first_open_count(_pfo)=0, system_app(_sys)=0, update_with_analytics(_uwa)=0, system_app_update(_sysu)=0}]}
03-02 14:38:55.531 5298 6500 V FA-SVC : Upload scheduled in approximately ms: 500
03-02 14:38:55.533 5298 6500 V FA-SVC : Cancelling job. JobID: 812057698
03-02 14:38:55.543 5298 6500 V FA-SVC : Scheduling upload with DelayedRunnable
03-02 14:38:55.543 5298 6500 V FA-SVC : Scheduling upload with GcmTaskService
03-02 14:38:55.543 5298 6500 V FA-SVC : Scheduling task with Gcm. time: 500
03-02 14:38:55.546 5298 6500 V FA-SVC : Background event processing time, ms: 53
03-02 14:38:55.554 5298 6500 V FA-SVC : Logging event: origin=auto,name=user_engagement(_e),params=Bundle[{engagement_time_msec(_et)=1}]
03-02 14:38:55.559 5298 6500 V FA-SVC : Saving event, name, data size: user_engagement(_e), 23
03-02 14:38:55.559 5298 6500 V FA-SVC : Event recorded: Event{appId='com.example.crashtest', name='user_engagement(_e)', params=Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=1}]}
03-02 14:38:55.560 5298 6500 V FA-SVC : Upload scheduled in approximately ms: 9970
03-02 14:38:55.561 5298 6500 V FA-SVC : Cancelling job. JobID: 812057698
03-02 14:38:55.570 5298 6500 V FA-SVC : Scheduling upload with DelayedRunnable
03-02 14:38:55.571 5298 6500 V FA-SVC : Scheduling upload with GcmTaskService
03-02 14:38:55.571 5298 6500 V FA-SVC : Scheduling task with Gcm. time: 9970
03-02 14:38:55.576 5298 6500 V FA-SVC : Background event processing time, ms: 23
03-02 14:38:55.606 5298 6500 V FA-SVC : Logging event: origin=auto,name=screen_view(_vs),params=Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=7340565616438629574}]
03-02 14:38:55.609 5298 6500 V FA-SVC : Saving event, name, data size: screen_view(_vs), 52
03-02 14:38:55.609 5298 6500 V FA-SVC : Event recorded: Event{appId='com.example.crashtest', name='screen_view(_vs)', params=Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=7340565616438629574}]}
03-02 14:38:55.611 5298 6500 V FA-SVC : Upload scheduled in approximately ms: 9919
03-02 14:38:55.612 5298 6500 V FA-SVC : Cancelling job. JobID: 812057698
03-02 14:38:55.616 5298 6500 V FA-SVC : Scheduling upload with DelayedRunnable
03-02 14:38:55.619 5298 6500 V FA-SVC : Scheduling upload with GcmTaskService
03-02 14:38:55.620 5298 6500 V FA-SVC : Scheduling task with Gcm. time: 9919
03-02 14:38:55.624 5298 6500 V FA-SVC : Background event processing time, ms: 19
03-02 14:38:55.638 5298 6500 V FA-SVC : Logging event: origin=auto,name=session_start(_s),params=Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=7340565616438629574}]
03-02 14:38:55.644 5298 6500 V FA-SVC : Saving event, name, data size: session_start(_s), 52
03-02 14:38:55.644 5298 6500 V FA-SVC : Event recorded: Event{appId='com.example.crashtest', name='session_start(_s)', params=Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=7340565616438629574}]}
03-02 14:38:55.646 5298 6500 V FA-SVC : Upload scheduled in approximately ms: 9884
03-02 14:38:55.647 5298 6500 V FA-SVC : Cancelling job. JobID: 812057698
03-02 14:38:55.654 5298 6500 V FA-SVC : Scheduling upload with DelayedRunnable
03-02 14:38:55.655 5298 6500 V FA-SVC : Scheduling upload with GcmTaskService
03-02 14:38:55.655 5298 6500 V FA-SVC : Scheduling task with Gcm. time: 9884
03-02 14:38:55.658 5298 6500 V FA-SVC : Background event processing time, ms: 21
03-02 14:38:55.673 5298 6500 V FA-SVC : Logging event: origin=auto,name=user_engagement(_e),params=Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=29900, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=7340565616438629574}]
03-02 14:38:55.678 5298 6500 V FA-SVC : Saving event, name, data size: user_engagement(_e), 68
03-02 14:38:55.678 5298 6500 V FA-SVC : Event recorded: Event{appId='com.example.crashtest', name='user_engagement(_e)', params=Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=29900, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=7340565616438629574}]}
03-02 14:38:55.680 5298 6500 V FA-SVC : Upload scheduled in approximately ms: 9850
03-02 14:38:55.681 5298 6500 V FA-SVC : Cancelling job. JobID: 812057698
03-02 14:38:55.684 5298 6500 V FA-SVC : Scheduling upload with DelayedRunnable
03-02 14:38:55.685 5298 6500 V FA-SVC : Scheduling upload with GcmTaskService
03-02 14:38:55.685 5298 6500 V FA-SVC : Scheduling task with Gcm. time: 9850
03-02 14:38:55.689 5298 6500 V FA-SVC : Background event processing time, ms: 15
03-02 14:38:55.704 5298 6500 V FA-SVC : Logging event: origin=auto,name=screen_view(_vs),params=Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-2098017139612028370}]
03-02 14:38:55.709 5298 6500 V FA-SVC : Saving event, name, data size: screen_view(_vs), 58
03-02 14:38:55.709 5298 6500 V FA-SVC : Event recorded: Event{appId='com.example.crashtest', name='screen_view(_vs)', params=Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-2098017139612028370}]}
03-02 14:38:55.711 5298 6500 V FA-SVC : Upload scheduled in approximately ms: 9819
03-02 14:38:55.711 5298 6500 V FA-SVC : Cancelling job. JobID: 812057698
03-02 14:38:55.713 5298 6500 V FA-SVC : Scheduling upload with DelayedRunnable
03-02 14:38:55.714 5298 6500 V FA-SVC : Scheduling upload with GcmTaskService
03-02 14:38:55.714 5298 6500 V FA-SVC : Scheduling task with Gcm. time: 9819
03-02 14:38:55.717 5298 6500 V FA-SVC : Background event processing time, ms: 14
03-02 14:39:00.737 6461 6496 V FA : Inactivity, disconnecting from the service
03-02 14:39:05.538 5298 6500 V FA-SVC : Cancelling job. JobID: 812057698
03-02 14:39:05.540 5298 6500 V FA-SVC : Starting upload from DelayedRunnable
03-02 14:39:05.545 5298 6500 D FA-SVC : Uploading events. Elapsed time since last upload attempt (ms): 10011
03-02 14:39:05.553 5298 6500 V FA-SVC : Fetching remote configuration: com.example.crashtest
03-02 14:39:05.556 5298 6500 V FA-SVC : Not stopping services. fetch, network, upload: true, false, false
03-02 14:40:05.774 5298 6660 V FA-SVC : onConfigFetched. Response size: 0
03-02 14:40:05.775 5298 6660 V FA-SVC : Fetching config failed. code, error: 0, java.net.SocketTimeoutException: connect timed out
03-02 14:40:05.788 5298 6660 V FA-SVC : Upload scheduled in approximately ms: 1809987
03-02 14:40:05.789 5298 6660 V FA-SVC : Cancelling job. JobID: 812057698
03-02 14:40:05.791 5298 6660 V FA-SVC : Scheduling upload with GcmTaskService
03-02 14:40:05.791 5298 6660 V FA-SVC : Scheduling task with Gcm. time: 1809987
03-02 14:40:05.804 5298 6660 V FA-SVC : Stopping uploading service(s)
03-02 14:40:31.723 6461 6711 D FA : Minimum session duration set: 108000
03-02 14:40:31.723 6461 6711 D FA : Setting app measurement enabled (FE): true
03-02 14:40:31.723 6461 6711 V FA : Setting measurementEnabled: true
03-02 14:40:31.725 6461 6711 V FA : Using measurement service
03-02 14:40:31.725 6461 6711 V FA : Connecting to remote service
03-02 14:40:31.760 6461 6711 D FA : Connected to remote service
03-02 14:40:31.760 6461 6711 V FA : Processing queued up service tasks: 1
03-02 14:40:36.764 6461 6711 V FA : Inactivity, disconnecting from the service
03-02 14:41:18.026 6461 6825 D FA : Logging event (FE): AppStartup, Bundle[{firebase_event_origin(_o)=app, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-2098017139612028370, hello=there}]
03-02 14:41:18.042 6461 6825 V FA : Using measurement service
03-02 14:41:18.042 6461 6825 V FA : Connecting to remote service
03-02 14:41:18.053 6461 6825 D FA : Connected to remote service
03-02 14:41:18.053 6461 6825 V FA : Processing queued up service tasks: 1
03-02 14:41:18.062 5298 6826 V FA-SVC : Logging event: origin=app,name=AppStartup,params=Bundle[{firebase_event_origin(_o)=app, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-2098017139612028370, hello=there}]
03-02 14:41:18.075 5298 6826 V FA-SVC : Saving event, name, data size: AppStartup, 68
03-02 14:41:18.075 5298 6826 V FA-SVC : Event recorded: Event{appId='com.example.crashtest', name='AppStartup', params=Bundle[{firebase_event_origin(_o)=app, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-2098017139612028370, hello=there}]}
03-02 14:41:18.077 5298 6826 V FA-SVC : Upload scheduled in approximately ms: 500
03-02 14:41:18.583 5298 6826 V FA-SVC : Cancelling job. JobID: 812057698
03-02 14:41:18.587 5298 6826 V FA-SVC : Starting upload from DelayedRunnable
03-02 14:41:18.588 5298 6826 D FA-SVC : Uploading events. Elapsed time since last upload attempt (ms): 511
03-02 14:41:18.590 5298 6826 V FA-SVC : Fetching remote configuration: com.example.crashtest
03-02 14:41:18.594 5298 6826 V FA-SVC : Not stopping services. fetch, network, upload: true, false, false
03-02 14:41:23.063 6461 6825 V FA : Inactivity, disconnecting from the service
03-02 14:42:18.990 5298 6958 V FA-SVC : onConfigFetched. Response size: 0
03-02 14:42:18.991 5298 6958 V FA-SVC : Fetching config failed. code, error: 0, java.net.SocketTimeoutException: connect timed out
03-02 14:42:18.993 5298 6958 V FA-SVC : Upload scheduled in approximately ms: 1809998
03-02 14:42:18.994 5298 6958 V FA-SVC : Cancelling job. JobID: 812057698
03-02 14:42:18.998 5298 6958 V FA-SVC : Scheduling upload with GcmTaskService
03-02 14:42:18.998 5298 6958 V FA-SVC : Scheduling task with Gcm. time: 1809998
03-02 14:42:19.008 5298 6958 V FA-SVC : Stopping uploading service(s)

This is from the application output window from VS2017:

[Mono] Assembly Ref addref Xamarin.GooglePlayServices.Tasks[0xa7322ac0] -> Mono.Android[0xa7322b20]: 33
[FirebaseApp] com.google.firebase.auth.FirebaseAuth is not linked. Skipping initialization.
[FirebaseApp] com.google.firebase.crash.FirebaseCrash is not linked. Skipping initialization.
[FA] App measurement is starting up, version: 11400
[FA] To enable debug logging run: adb shell setprop log.tag.FA VERBOSE
[FA] Collection enabled
[FA] App package, google app id: com.example.crashtest, 1:75859314137:android:eh18at2sx84fvwxo
[FA] To enable faster debug mode event logging run:
[FA] adb shell setprop debug.firebase.analytics.app com.example.crashtest
[FA] Debug-level message logging enabled
[FA] Cancelling job. JobID: -1962091572
[FA] Registered activity lifecycle callback
[FirebaseInitProvider] FirebaseApp initialization successful
... cut
[Mono] Assembly Ref addref Xamarin.Forms.Platform.Android[0xa7322940] -> mscorlib[0xa7321920]: 38
[FA] Using measurement service
[FA] Connecting to remote service
... cut
[FA] Using measurement service
[FA] Connection attempt already in progress
... cut
[FA] onActivityCreated
... cut
[art] JNI RegisterNativeMethods: attempt to register 0 native methods for md58432a647068b097f9637064b8985a5e0.ViewRenderer_2
... cut
Loaded assembly: System.Xml.dll [External]
... cut
[art] JNI RegisterNativeMethods: attempt to register 0 native methods for md51558244f76c53b6aeda52c8a337f2c37.EntryRenderer
... cut
[FA] Using measurement service
[FA] Connection attempt already in progress
[FA] Activity resumed, time: 395545
[FA] Tag Manager is not found and thus will not be used
[FA] Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-2098017139612028370}]
[] HostConnection::get() New Host Connection established 0x92df3f40, tid 6461
[FA] Using measurement service
[FA] Connection attempt already in progress
[] HostConnection::get() New Host Connection established 0x92ccc3c0, tid 6497
[OpenGLRenderer] Initialized EGL, version 1.4
[OpenGLRenderer] Swap behavior 1
[OpenGLRenderer] Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
[OpenGLRenderer] Swap behavior 0
... cut
[View] requestLayout() improperly called by md51558244f76c53b6aeda52c8a337f2c37.ScrollViewContainer{92cb1fa V.E...... ......ID 0,0-1080,1750} during layout: running second layout pass
[EGL_emulation] eglMakeCurrent: 0xa9e85420: ver 3 0 (tinfo 0x9327e220)
[FA] Connected to remote service
[FA] Processing queued up service tasks: 4
Thread started: #4
Thread started: #5
Thread started: #6
Thread started: #7
[FA] Inactivity, disconnecting from the service
Thread finished: #4
[Mono] Assembly Ref addref crashtest.Android[0xa7321aa0] -> Xamarin.Firebase.Analytics.Impl[0xa73227c0]: 2
[Mono] Assembly Ref addref crashtest.Android[0xa7321aa0] -> System[0x93691ea0]: 5
[FA] Minimum session duration set: 108000
[FA] Setting app measurement enabled (FE): true
[FA] Setting measurementEnabled: true
[FA] Using measurement service
[FA] Connecting to remote service
[OpenGLRenderer] endAllActiveAnimators on 0x919ecd00 (RippleDrawable) with handle 0x9327ef10
[FA] Connected to remote service
[FA] Processing queued up service tasks: 1
[FA] Inactivity, disconnecting from the service
Thread finished: #8
Thread started: #9
[FA] Logging event (FE): AppStartup, Bundle[{firebase_event_origin(_o)=app, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-2098017139612028370, hello=there}]
[FA] Using measurement service
[FA] Connecting to remote service
[FA] Connected to remote service
[FA] Processing queued up service tasks: 1
[FA] Inactivity, disconnecting from the service

Answers

  • truckbranchtruckbranch Member ✭✭

    Here is the Android DI code:

    using System;
    using System.Collections.Generic;
    using Android.OS;
    using crashtest.Helper;
    using crashtest.Model;
    using Firebase.Analytics;
    
    [assembly: Xamarin.Forms.Dependency(typeof(crashtest.Droid.Implementation.Analytics_Android))]
    namespace crashtest.Droid.Implementation
    {
        public class Analytics_Android : IAnalytics
        {
            private bool analyticsEnabled = false;
            private FirebaseAnalytics firebaseAnalytics = null;
    
            public bool AnalyticsDisable()
            {
                bool error = SendAnalyticsCollection(false);
                return error;
            }
    
            public bool AnalyticsEnable()
            {
                bool error = SendAnalyticsCollection(true);
                return error;
            }
    
            private bool SetFirebaseInstance()
            {
                try
                {
                    var context = Android.App.Application.Context;
                    firebaseAnalytics = FirebaseAnalytics.GetInstance(context);
                    firebaseAnalytics.SetMinimumSessionDuration(108000);
                }
                catch (Exception exception)
                {
                    return true;
                }
    
                return false;
            }
    
            private bool SendAnalyticsCollection(bool send)
            {
                bool error;
                try
                {
                    if (firebaseAnalytics == null)
                    {
                        error = SetFirebaseInstance();
                        if (error)
                        {
                            return error;
                        }
                    }
                    firebaseAnalytics.SetAnalyticsCollectionEnabled(send);
                    analyticsEnabled = send;
                }
                catch (Exception exception)
                {
                    return true;
                }
    
                return false;
            }
    
            public bool AnalyticsSetUserProp(string prop, string value)
            {
                bool error;
                try
                {
                    if (analyticsEnabled)
                    {
                        if (firebaseAnalytics == null)
                        {
                            error = SetFirebaseInstance();
                            if (error)
                            {
                                return error;
                            }
                        }
                        firebaseAnalytics.SetUserProperty(prop, value);
                    }
                }
                catch (Exception exception)
                {
                    return true;
                }
    
                return false;
            }
    
            public bool AnalticsLogEvent(string eventName, Dictionary<string, string> keyValues)
            {
                bool error;
                try
                {
                    if (analyticsEnabled)
                    {
                        if (firebaseAnalytics == null)
                        {
                            error = SetFirebaseInstance();
                            if (error)
                            {
                                return error;
                            }
                        }
                        var p = new Bundle();
                        foreach (var keyValue in keyValues)
                        {
                            p.PutString(keyValue.Key, keyValue.Value);
                        }
                        firebaseAnalytics.LogEvent(eventName, p);
                    }
                }
                catch (Exception exception)
                {
                    return true;
                }
    
                return false;
            }
        }
    }
    
  • truckbranchtruckbranch Member ✭✭

    I forgot to note: Google Firebase Crashlytics works fine, so I think that the google-services.json file is binding correctly - at least to that service.

Sign In or Register to comment.