问题
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?
回答1:
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.
回答2:
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.
回答3:
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
回答4:
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
回答5:
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
{...}
]
回答6:
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
来源:https://stackoverflow.com/questions/50138152/debugview-no-devices-available