Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase analytics AppMeasurement not enabled

Tags:

I have followed all the instructions for integrating Firebase analytics correctly in my project. But when I enable debug logging to make sure the events are being sent (using instructions from here) I see

E/FA      ( 3556): AppMeasurementReceiver not registered/enabled
E/FA      ( 3556): AppMeasurementService not registered/enabled
E/FA      ( 3556): Uploading is not possible. App measurement disabled

and obviously the events are not being sent.

Again I have followed all the instructions .

like image 401
Kayvan N Avatar asked Sep 13 '16 23:09

Kayvan N


People also ask

How do I enable Google Analytics on Firebase?

If you need to deactivate Analytics collection permanently in a version of your app, set FIREBASE_ANALYTICS_COLLECTION_DEACTIVATED to YES (Boolean) in your app's Info.

How do I initialize Firebase Analytics?

Declare the FirebaseAnalytics object at the top of your activity: private FirebaseAnalytics mFirebaseAnalytics; Then initialize it in the onCreate() method: mFirebaseAnalytics = FirebaseAnalytics.


3 Answers

It turns out that Firebase Library has an Android Manifest file in which it defines these nodes:

 <service android:name="com.google.android.gms.measurement.AppMeasurementService"
     android:enabled="true"
     android:exported="false"/>

 <receiver android:name="com.google.android.gms.measurement.AppMeasurementReceiver"
     android:enabled="true">
     <intent-filter>
         <action android:name="com.google.android.gms.measurement.UPLOAD" />
     </intent-filter>
 </receiver>

based on AppMeasurementService and AppMeasurementReceiver

which are needed for analytics to work and my problem was that I was replacing all the library nodes with <tools:node=”replace”> in my Android Manifest which in turn ignored the needed nodes for analytics lib.

Removing <tools:node=”replace”> and replacing my conflicts specifically solved my problem.

like image 130
Kayvan N Avatar answered Sep 19 '22 17:09

Kayvan N


Make sure you set mata data at the manifest firebase_analytics_collection_enabled to be true

<meta-data
     android:name="firebase_analytics_collection_enabled"
     android:value="true" />
like image 38
ilham suaib Avatar answered Sep 19 '22 17:09

ilham suaib


In my case, a library I was using was including Firebase but explictly disabling analytics in their manifest.

So I had to override that setting in my AndroidManifest.xml to enable analytics with the following (just before the </application> tag):

<meta-data android:name="firebase_analytics_collection_deactivated" android:value="false"
                   tools:replace="android:value"/>
like image 27
Sean Barbeau Avatar answered Sep 21 '22 17:09

Sean Barbeau