AbdFatah / analytics-issues

Automatically exported from code.google.com/p/analytics-issues
0 stars 0 forks source link

NullPointerException on track page #228

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Name of affected component: Mobile Tracking

Name of related library and version, if applicable (e.g. Android, iOS,
Snippets, etc.): Android Google Analytics SDK r2

Issue summary:
I've integrated Google Analytics SDK using EasyTracker, for some reason 
GoogleAnalyticsTracker.getInstance() returns null in some devices, reproduced 
in T-Mobile HTC One S with Android 4.03

Stacktrace:
E/AndroidRuntime(20340): FATAL EXCEPTION: TrackerThread
E/AndroidRuntime(20340): java.lang.NullPointerException
E/AndroidRuntime(20340):    at 
com.google.android.apps.analytics.GoogleAnalyticsTracker.createEvent(Unknown 
Source)
E/AndroidRuntime(20340):    at 
com.google.android.apps.analytics.GoogleAnalyticsTracker.trackPageView(Unknown 
Source)
E/AndroidRuntime(20340):    at 
com.google.android.apps.analytics.easytracking.GoogleAnalyticsTrackerDelegateImp
l.trackPageView(GoogleAnalyticsTrackerDelegateImpl.java:39)
E/AndroidRuntime(20340):    at 
com.google.android.apps.analytics.easytracking.EasyTracker$12.run(EasyTracker.ja
va:474)
E/AndroidRuntime(20340):    at 
com.google.android.apps.analytics.easytracking.EasyTracker$TrackerThread.run(Eas
yTracker.java:580)

Steps to reproduce issue:
1. Integrate EasyTracker and Google Analytics as usual
2. Track a pageView on Activity create
3. Open that activity from in example a Notification with Intent created with 
context and class, pending intent has FLAG_CANCEL_CURRENT

Expected output:
A regular page view call instead of  java.lang.NullPointerException

Actual results:
 java.lang.NullPointerException with stacktrace

Stacktrace:
E/AndroidRuntime(20340): FATAL EXCEPTION: TrackerThread
E/AndroidRuntime(20340): java.lang.NullPointerException
E/AndroidRuntime(20340):    at 
com.google.android.apps.analytics.GoogleAnalyticsTracker.createEvent(Unknown 
Source)
E/AndroidRuntime(20340):    at 
com.google.android.apps.analytics.GoogleAnalyticsTracker.trackPageView(Unknown 
Source)
E/AndroidRuntime(20340):    at 
com.google.android.apps.analytics.easytracking.GoogleAnalyticsTrackerDelegateImp
l.trackPageView(GoogleAnalyticsTrackerDelegateImpl.java:39)
E/AndroidRuntime(20340):    at 
com.google.android.apps.analytics.easytracking.EasyTracker$12.run(EasyTracker.ja
va:474)
E/AndroidRuntime(20340):    at 
com.google.android.apps.analytics.easytracking.EasyTracker$TrackerThread.run(Eas
yTracker.java:580)

Notes:
Reproduced in T-Mobile HTC One S with Android 4.03

Original issue reported on code.google.com by eveli...@gmail.com on 24 Aug 2012 at 8:43

GoogleCodeExporter commented 9 years ago
Am also seeing this exact problem. Faintly annoying there's no source code.

Original comment by reuben.s...@gmail.com on 5 Sep 2012 at 10:43

GoogleCodeExporter commented 9 years ago
On further inspection this appears to be a race condition in EasyTracker.java. 
It's caused by tracking a page before the Runnable in initializeTracker() has 
run. It's pretty easy to refactor EasyTracker.java to avoid this.

Original comment by reuben.s...@gmail.com on 5 Sep 2012 at 12:24

GoogleCodeExporter commented 9 years ago
Hi, we have exactly the same issue with the same GA version. We are directly 
using the GA api instead of EasyTracker. Occurs only after a long idle time of 
the mobile application, in the OnResume() of an activity.

Anyone any ideas or tips?

Original comment by bart.pla...@gmail.com on 7 Sep 2012 at 6:42

GoogleCodeExporter commented 9 years ago
Yes. You are sending a trackPage when there is no current session. You may be 
doing EasyTracker.startSession() correctly but if you debug the call you'll see 
your startSession() doesn't actually do anything because EasyTracker's worker 
thread hasn't yet started. Hence no current session for the trackPage() call.

Original comment by reuben.s...@gmail.com on 7 Sep 2012 at 9:17

GoogleCodeExporter commented 9 years ago
I got today the exact same issue. Occured when my phone woke up from a long 
idle time. It's obvious that the tracker is not properly initialized by the 
time it's been called from startSession() or even trackPage() / trackEvent(), 
question is: why? 

Original comment by seriesad...@gmail.com on 20 Oct 2012 at 9:33

GoogleCodeExporter commented 9 years ago
Hi, I got many issues like that seeing in my ACRA, any tip how to solve this 
issue ? put startSession() in onStart event will solve this ? but it won't 
start twice or mess up results on GA ?

Thanks.

Original comment by ederson....@gmail.com on 26 Oct 2012 at 3:10

GoogleCodeExporter commented 9 years ago
Hi, I got many issues like this, any solution?

Original comment by hack...@gmail.com on 13 May 2013 at 5:52

GoogleCodeExporter commented 9 years ago

Original comment by awa...@google.com on 7 Nov 2013 at 9:10

GoogleCodeExporter commented 9 years ago
'Obsolete' because everyone's given up on GA's joke of an SDK?

Original comment by reuben.s...@gmail.com on 7 Nov 2013 at 9:16