2011-06-09 65 views
7

我使用谷歌分析(Android版),但接通後StrictMode我得到這樣的消息很多的:StrictMode +分析

StrictMode policy violation; ~duration=349 ms: android.os.StrictMode$StrictModeDiskReadViolation: policy=23 violation=2 
at android.os.StrictMode$AndroidBlockGuardPolicy.onReadFromDisk(StrictMode.java:745) 
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345) 
at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1235) 
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1189) 
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1309) 
at com.google.android.apps.analytics.PersistentEventStore.peekEvents(Unknown Source) 
at com.google.android.apps.analytics.PersistentEventStore.peekEvents(Unknown Source) 
at com.google.android.apps.analytics.GoogleAnalyticsTracker.dispatch(Unknown Source) 
at com.google.android.apps.analytics.GoogleAnalyticsTracker$1.run(Unknown Source) 
at android.os.Handler.handleCallback(Handler.java:587) 
at android.os.Handler.dispatchMessage(Handler.java:92) 
at android.os.Looper.loop(Looper.java:123) 
at android.app.ActivityThread.main(ActivityThread.java:3647) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:507) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
at dalvik.system.NativeStart.main(Native Method) 

我可以忽略? 我也嘗試將tracker.trackingPageView(...)放入AsyncTask - 相同的結果。

這裏是我的設置StrictMode:

StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder() 
    .detectDiskReads() 
    .detectDiskWrites() 
    .detectNetwork() 
    .penaltyLog() 
    .build()); 

    StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder() 
     .detectLeakedSqlLiteObjects() 
    .penaltyLog() 
    .penaltyDeath() 
    .build()); 

我真的很感激任何幫助 - 在此先感謝! Mike

+0

我最近有同樣的問題。我可以繞過我實際創建的所有事件,如trackPageView,但使用我自己的Handler或AsyncTask(儘管它看起來像移動API應該已經處理了),但由於我不控制調度,我不能解決這個問題。我認爲這只是現在的事情而已。我不知道該在哪裏報告,因爲目前移動分析SDK是一個「實驗室」項目。 – 2011-06-15 17:07:34

回答

6

查看iosched應用程序的AnalyticsUtils.java,該應用程序會在跟蹤調用中執行一些asynctask魔術。然而,這是在構造函數中:

// Unfortunately this needs to be synchronous. 
    mTracker.start(UACODE, 300, mApplicationContext); 
+0

Uuuuhhh,坦克!!!! – 2011-07-08 05:41:22

+2

不幸的是,這並不能解決我的問題。所有的調用都是在非UI線程中完成的,但我仍然看到StrictMode抱怨,因爲庫仍然訪問Handler中的一些SQLite數據庫(< - 在UI線程中)。 :( – BoD 2012-07-02 16:03:27

4

我可以忽略嗎?

你可能沒有選擇忽略這一點,希望分析團隊改善他們的代碼的一天。

+0

嗯,好的,謝謝。我希望來自GA-Team的人閱讀這篇文章 – 2011-06-14 08:22:06

+0

一年後,問題仍然存在於當前分析.jar中。煩人。 – 2012-08-10 09:07:53