paullangtree / analytics-issues

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

GoogleAnalytics.getInstance(Context) violates StrictMode #749

Open GoogleCodeExporter opened 8 years ago

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

Name of related library and version, if applicable (e.g. Android, iOS,
Snippets, etc.): Android 4.4, Play Services Analytics 8.1.0

Issue summary:
Calling GoogleAnalytics.getInstance(Context) during Application.onCreate() 
generates StrictMode violation with log below. We want to do some setup with 
the GA tracker instance during application startup. Not sure if we're not 
supposed to do this during application startup time, or this is indeed a 
violation?

StrictMode  D  StrictMode policy violation; ~duration=71 ms: 
android.os.StrictMode$StrictModeDiskReadViolation: policy=2111 violation=2
StrictMode  D  at 
android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:113
5)
StrictMode  D  at libcore.io.BlockGuardOs.open(BlockGuardOs.java:106)
StrictMode  D  at libcore.io.IoBridge.open(IoBridge.java:393)
StrictMode  D  at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
StrictMode  D  at java.io.FileOutputStream.<init>(FileOutputStream.java:73)
StrictMode  D  at 
android.app.SharedPreferencesImpl.createFileOutputStream(SharedPreferencesImpl.j
ava:543)
StrictMode  D  at 
android.app.SharedPreferencesImpl.writeToFile(SharedPreferencesImpl.java:591)
StrictMode  D  at 
android.app.SharedPreferencesImpl.access$800(SharedPreferencesImpl.java:52)
StrictMode  D  at 
android.app.SharedPreferencesImpl$2.run(SharedPreferencesImpl.java:511)
StrictMode  D  at 
android.app.SharedPreferencesImpl.enqueueDiskWrite(SharedPreferencesImpl.java:53
2)
StrictMode  D  at 
android.app.SharedPreferencesImpl.access$100(SharedPreferencesImpl.java:52)
StrictMode  D  at 
android.app.SharedPreferencesImpl$EditorImpl.commit(SharedPreferencesImpl.java:4
54)
StrictMode  D  at 
com.google.android.gms.analytics.internal.zzai$zza.zzkU(Unknown Source)
StrictMode  D  at 
com.google.android.gms.analytics.internal.zzai$zza.zzbn(Unknown Source)
StrictMode  D  at com.google.android.gms.analytics.internal.zzaf.zzb(Unknown 
Source)
StrictMode  D  at com.google.android.gms.analytics.internal.zzaf.zza(Unknown 
Source)
StrictMode  D  at com.google.android.gms.analytics.internal.zzc.zza(Unknown 
Source)
StrictMode  D  at com.google.android.gms.analytics.internal.zzc.zzbd(Unknown 
Source)
StrictMode  D  at com.google.android.gms.analytics.internal.zzl.zzjc(Unknown 
Source)
StrictMode  D  at com.google.android.gms.analytics.internal.zzl.start(Unknown 
Source)
StrictMode  D  at com.google.android.gms.analytics.internal.zzb.start(Unknown 
Source)
StrictMode  D  at com.google.android.gms.analytics.internal.zzf.<init>(Unknown 
Source)
StrictMode  D  at com.google.android.gms.analytics.internal.zzf.zzX(Unknown 
Source)
StrictMode  D  at 
com.google.android.gms.analytics.GoogleAnalytics.getInstance(Unknown Source)
StrictMode  D  at xxxApplication.initGoogleAnalytics(xxxApplication.java:94)
StrictMode  D  at xxxApplication.onCreate(xxxApplication.java:49)
StrictMode  D  at xxxApplication.onCreate(xxxApplication.java:48)
StrictMode  D  at 
android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
StrictMode  D  at 
android.app.ActivityThread.handleBindApplication(ActivityThread.java:4328)
StrictMode  D  at 
android.app.ActivityThread.access$1500(ActivityThread.java:135)
StrictMode  D  at 
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
StrictMode  D  at android.os.Handler.dispatchMessage(Handler.java:102)
StrictMode  D  at android.os.Looper.loop(Looper.java:136)
StrictMode  D  at android.app.ActivityThread.main(ActivityThread.java:5001)
StrictMode  D  at java.lang.reflect.Method.invokeNative(Native Method)
StrictMode  D  at java.lang.reflect.Method.invoke(Method.java:515)
StrictMode  D  at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
StrictMode  D  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
StrictMode  D  at dalvik.system.NativeStart.main(Native Method)

Expected output:
No StrictMode violation observed

Actual results:
StrictMode violation generated

Original issue reported on code.google.com by haduytr...@gmail.com on 6 Oct 2015 at 2:59