7

I'm doing some tests on a small app to understand how firebase-analytics works. This is the code for the MainActivity:

public class MainActivity extends AppCompatActivity {
private FirebaseAnalytics mFirebaseAnalytics;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mFirebaseAnalytics = FirebaseAnalytics.getInstance(getApplicationContext());

    mFirebaseAnalytics.setAnalyticsCollectionEnabled(true);

    mFirebaseAnalytics.setMinimumSessionDuration(10000);

    mFirebaseAnalytics.setSessionTimeoutDuration(300);

    Bundle bundle = new Bundle();
    bundle.putString(FirebaseAnalytics.Param.ITEM_ID,"ID");
    bundle.putString(FirebaseAnalytics.Param.ITEM_NAME,"NAME");
    bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE,"image");

    mFirebaseAnalytics.logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle);
}

To see if my app send data to Firebase I tryed to use DebugView but it says that there isn't any devices available, i also used the command

adb shell setprop debug.firebase.analytics.app <package_name>  

but nothing changed.
If i use these 3 commands

adb shell setprop log.tag.FA VERBOSE
adb shell setprop log.tag.FA-SVC VERBOSE
adb logcat -v time -s FA FA-SVC

i can see that my app is sending some data to firebase, like in this picture

What can i do to enable DebugView and see what my app send to firebase in real time?

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
Igor Turchi
  • 73
  • 1
  • 1
  • 4
  • I had an experience with DebugView where is seemed I needed to close and reopen the Firebase Console tab in my browser (Chrome) to get it to start displaying events. Give that a try. – Bob Snyder May 02 '18 at 17:47
  • is this issue fixed? – Mohit Dholakia Mar 06 '20 at 11:59
  • potential duplicate of https://stackoverflow.com/questions/42769236/firebase-analytics-debug-view-does-not-show-anything – Anton Oct 25 '20 at 12:16

8 Answers8

9

Please ensure that the following steps have been followed:

Step 1: Your app is properly configured in the Firebase console to support the Analytics features.

Step 2:

A) If you are simply working with single build variant, the following command is enough:

adb shell setprop debug.firebase.analytics.app [your_app_package_name]

B) But if you are working with multiple build variants with different application IDs which are not the same as the app package name, be sure to execute the following command:

adb shell setprop debug.firebase.analytics.app [your_application_id]

Here, application ID is the app ID of your build variant found in the corresponding gradle file. For example, lets say you have x.gradle and y.gradle for two build variants x and y, and you also have the general build.gradle file. To debug the build variant x with application ID com.abc.x, the command will be:

adb shell setprop debug.firebase.analytics.app com.abc.x

Similarly, to debug the build variant y with application ID com.abc.y, the command will be:

adb shell setprop debug.firebase.analytics.app com.abc.y

This behavior persists until you explicitly disable it by executing the following command:

adb shell setprop debug.firebase.analytics.app .none.
M. Arabi Hasan Sakib
  • 2,626
  • 2
  • 13
  • 20
4

I had the same symptoms as you did. In my case the problem was simply because I forgot to turn on WiFi, so events couldn't be propagated to cloud but were appearing in logcat.

LLL
  • 1,777
  • 1
  • 15
  • 31
2

I've spent insane amount of time debugging this, and my conclusion - it is the Firebase instability, because I get events intermittently, and there is no pattern to what makes them appear in that DebugView

Alexei Masterov
  • 382
  • 2
  • 10
1

You can see your list of devices -> adb devices

and then -> adb shell setprop debug.firebase.analytics.app package_name

after that, in Android Studio, run by Debug

tomerpacific
  • 4,704
  • 13
  • 34
  • 52
1

Ok for me.... the reason was because I was having this on my second screen =>

enter image description here

Lessons learnt:

  1. Android Emulators messes up with the ADB and have an impact on firebase debug view.
  2. Don't play games during work... It's 'DIRECTLY' counter productive.
user1034912
  • 2,153
  • 7
  • 38
  • 60
0

This command will be helpful to see debug view in firebase analytics:

adb shell setprop debug.firebase.analytics.app

One additional note specified in firebase Google support

Note: Before using DebugView, you should ensure that your device time is accurate. A skewed device clock will result in delayed or missing events in your Analytics reports.

You can refere to below link : https://support.google.com/firebase/answer/7201382?hl=en

0

My situation may not be relevant but posting for my future sanity if nothing else.

I had created a new project in firebase and also was having the problem where it said the 'Finish the sdk setup' error trying to communicate with my application (which I had just finished renaming the android package-prompting to create a new project in Firebase)

I was trying to get debugging to work to 'kick' it into connecting, but was getting not devices so I knew there was something wrong.

My issue was my google-services.json filed. It had a reference to my old project name in there AS WELL as my new one. So maybe it was getting confused?

Under client, there were two objects with client_info, api_key, etc. I removed the old one, leaving only the newer correct one.

  "client": [
    {...}, // <-- removed this one
    {...}
  ]

Taylor A. Leach
  • 2,115
  • 4
  • 25
  • 43
  • right but some of us have multiple environments (that are not "old" as yours was) and it's supposed to be smart enough to know to take the client data that matches the app's current package name – tar Mar 23 '21 at 14:53
0

Make sure you haven't disabled Firebase Analytics logging either on Gradle or on your manifest.

rodmaia
  • 179
  • 6