Search code examples
androidgoogle-analyticsgoogle-analytics-api

Google Analytics Easy Tracker Memory Issues


I am trying to integrate Google Analytics in my Activities. As per the official documentation i used the "Easy Tracker" Library provided by Google and extended my activities from "TrackedActivity" The exact syntax i use is:

EasyTracker.getTracker().trackPageView("/myview"+viewname);

I am getting Null Pointer Exception randomly but Logcat shows "at Google Analytics" and surprisingly not at any place in my code. In some of my activities, I am calling system.gc() function in the onDestroy() method. (Could be the issue) Its supposed to be a singleton object I am worried if its getting garbage collected?

Needless to say as of now my app crashes. What worries me further is that even if i do a try catch or put exception checkers ie. check across null object. I am still worried that my activities might not get tracked even if the Crash is avoided.

Please Suggest.


Solution

  • Make sure that you don't invoke methods of EasyTracker before onStart() of your Activity. Also set ga_debug and ga_auto_activity_tracking to "true" to get debug statements and to track all activities of the application respectively.