当我尝试使用Google Analytics时,我在尝试使用User-Id时出现问题:
public class MyApplication extends Application {
public static GoogleAnalytics analytics;
public static Tracker tracker;
@Override
public void onCreate() {
super.onCreate();
DatabaseManager.initializeInstance(new DatabaseHandler(this));
analytics = GoogleAnalytics.getInstance(this);
analytics.setLocalDispatchPeriod(1800);
tracker = analytics.newTracker("UA-XXXXXX-2"); // Replace with actual tracker/property Id
tracker.enableExceptionReporting(true);
tracker.enableAdvertisingIdCollection(true);
tracker.enableAutoActivityTracking(true);
}
在我的BaseActivity.java中,我启用了实时报告:
@Override
public void onStart() {
super.onStart();
GoogleAnalytics.getInstance(this).reportActivityStart(this);
}
@Override
protected void onStop() {
super.onStop();
GoogleAnalytics.getInstance(this).reportActivityStop(this);
}
此代码运行并且没问题。
激发ANR的代码在我的SplashScreenActivity.java中:
MyApplication.tracker.set("&uid", mUser.userName);
MyApplication.tracker.send(new HitBuilders.EventBuilder().setCategory("UX").setAction("Getting Username").build());
这是ANR的日志
----- pid 14019 at 2015-06-04 16:25:28 -----
Cmd line: com.myapp.mobile
DALVIK THREADS:
(mutexes: tll=0 tsl=0 tscl=0 ghl=0)
"main" prio=5 tid=1 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41457508 self=0x414478e0
| sysTid=14019 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1074728752
| schedstat=( 248687749 130187981 316 ) utm=17 stm=7 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x414575d8> (a java.lang.VMThread) held by tid=1 (main)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:813)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(AbstractQueuedSynchronizer. java:973)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer. java:1282)
at java.util.concurrent.FutureTask$Sync.innerGet(FutureTask.java:219)
at java.util.concurrent.FutureTask.get(FutureTask.java:82)
at com.google.android.gms.analytics.internal.zzb.zzhI((null):-1)
at com.google.android.gms.analytics.GoogleAnalytics.zzhk((null):-1)
at com.google.android.gms.analytics.ExceptionReporter.uncaughtException((null):-1)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
at dalvik.system.NativeStart.main(Native Method)
"pool-2-thread-1" prio=5 tid=13 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41e978f0 self=0x5ad77398
| sysTid=14040 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1570148360
| schedstat=( 1953124 6256104 5 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x41e57ad0> (a java.lang.VMThread) held by tid=13 (pool-2-thread-1)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
"measurement-1" prio=5 tid=12 WAIT
| group="main" sCount=1 dsCount=0 obj=0x41e8b838 self=0x5b694310
| sysTid=14038 nice=10 sched=0/0 cgrp=[no-cpu-subsys] handle=1533839352
| schedstat=( 43182372 116882325 183 ) utm=4 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x41e8b910> (a java.lang.VMThread) held by tid=12 (measurement-1)
at java.lang.Thread.parkFor(Thread.java:1231)
at sun.misc.Unsafe.park(Unsafe.java:323)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
at com.google.android.gms.common.zza.zzmh((null):-1)
at com.google.android.gms.ads.identifier.AdvertisingIdClient.zza((null):-1)
at com.google.android.gms.ads.identifier.AdvertisingIdClient.zzb((null):-1)
at com.google.android.gms.ads.identifier.AdvertisingIdClient.getAdvertisingIdInfo((null):-1)
at com.google.android.gms.analytics.internal.zza.zzhE((null):-1)
at com.google.android.gms.analytics.internal.zza.zzhD((null):-1)
at com.google.android.gms.analytics.internal.zza.zzhy((null):-1)
at com.google.android.gms.analytics.Tracker$1.run((null):-1)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
at com.google.android.gms.internal.zzns$zzc.run((null):-1)
"Binder_3" prio=5 tid=11 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41e24788 self=0x58dec838
| sysTid=14034 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1491007920
| schedstat=( 1373292 549317 4 ) utm=0 stm=0 core=1
#00 pc 0000cb70 /system/lib/libc.so (__ioctl+8)
#01 pc 00027e9d /system/lib/libc.so (ioctl+16)
#02 pc 00016bfd /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+124)
#03 pc 000173af /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 0001b171 /system/lib/libbinder.so
#05 pc 0001104f /system/lib/libutils.so (android::Thread::_threadLoop(void*)+114)
#06 pc 0004b44b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+66)
#07 pc 00010bb5 /system/lib/libutils.so
#08 pc 00012d70 /system/lib/libc.so (__thread_entry+48)
#09 pc 000124c8 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"Binder_2" prio=5 tid=10 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41e246c8 self=0x58def358
| sysTid=14033 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1491006064
| schedstat=( 1342774 4394532 6 ) utm=0 stm=0 core=1
#00 pc 0000cb70 /system/lib/libc.so (__ioctl+8)
#01 pc 00027e9d /system/lib/libc.so (ioctl+16)
#02 pc 00016bfd /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+124)
#03 pc 000173af /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 0001b171 /system/lib/libbinder.so
#05 pc 0001104f /system/lib/libutils.so (android::Thread::_threadLoop(void*)+114)
#06 pc 0004b44b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+66)
#07 pc 00010bb5 /system/lib/libutils.so
#08 pc 00012d70 /system/lib/libc.so (__thread_entry+48)
#09 pc 000124c8 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"Binder_1" prio=5 tid=9 NATIVE
| group="main" sCount=1 dsCount=0 obj=0x41e23578 self=0x58deec18
| sysTid=14032 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1533592384
| schedstat=( 3631592 20294190 10 ) utm=0 stm=0 core=0
#00 pc 0000cb70 /system/lib/libc.so (__ioctl+8)
#01 pc 00027e9d /system/lib/libc.so (ioctl+16)
#02 pc 00016bfd /system/lib/libbinder.so (android::IPCThreadState::talkWithDriver(bool)+124)
#03 pc 000173af /system/lib/libbinder.so (android::IPCThreadState::joinThreadPool(bool)+154)
#04 pc 0001b171 /system/lib/libbinder.so
#05 pc 0001104f /system/lib/libutils.so (android::Thread::_threadLoop(void*)+114)
#06 pc 0004b44b /system/lib/libandroid_runtime.so (android::AndroidRuntime::javaThreadShell(void*)+66)
#07 pc 00010bb5 /system/lib/libutils.so
#08 pc 00012d70 /system/lib/libc.so (__thread_entry+48)
#09 pc 000124c8 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"FinalizerWatchdogDaemon" daemon prio=5 tid=8 WAIT
| group="system" sCount=1 dsCount=0 obj=0x41e1f2a0 self=0x5b6967f0
| sysTid=14029 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1533593200
| schedstat=( 213624 610351 4 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x4145f170> (a java.lang.Daemons$FinalizerWatchdogDaemon)
at java.lang.Object.wait(Object.java:364)
at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:214)
at java.lang.Thread.run(Thread.java:856)
"FinalizerDaemon" daemon prio=5 tid=7 WAIT
| group="system" sCount=1 dsCount=0 obj=0x41e1f0f0 self=0x5b68b650
| sysTid=14028 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1093549952
| schedstat=( 762939 305176 4 ) utm=0 stm=0 core=0
at java.lang.Object.wait(Native Method)
- waiting on <0x4144d5d0> (a java.lang.ref.ReferenceQueue)
at java.lang.Object.wait(Object.java:401)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:102)
at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:73)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:169)
at java.lang.Thread.run(Thread.java:856)
"ReferenceQueueDaemon" daemon prio=5 tid=6 WAIT
| group="system" sCount=1 dsCount=0 obj=0x41e1ef88 self=0x5ad55b70
| sysTid=14027 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1094096120
| schedstat=( 488280 0 8 ) utm=0 stm=0 core=1
at java.lang.Object.wait(Native Method)
- waiting on <0x4144d4f8>
at java.lang.Object.wait(Object.java:364)
at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:129)
at java.lang.Thread.run(Thread.java:856)
"Compiler" daemon prio=5 tid=5 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x41e1ee98 self=0x41353928
| sysTid=14026 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1523974648
| schedstat=( 2044679 335693 3 ) utm=0 stm=0 core=0
#00 pc 0000dc80 /system/lib/libc.so (__futex_syscall3+8)
#01 pc 00012db4 /system/lib/libc.so (__pthread_cond_timedwait_relative+48)
#02 pc 00012e10 /system/lib/libc.so (__pthread_cond_timedwait+60)
#03 pc 0006f915 /system/lib/libdvm.so
#04 pc 00053b7f /system/lib/libdvm.so
#05 pc 00012d70 /system/lib/libc.so (__thread_entry+48)
#06 pc 000124c8 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"JDWP" daemon prio=5 tid=4 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x41e1edb0 self=0x5b68a4d8
| sysTid=14025 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1479479016
| schedstat=( 18951417 6988525 49 ) utm=1 stm=0 core=0
#00 pc 0000cc98 /system/lib/libc.so (select+20)
#01 pc 00060737 /system/lib/libdvm.so
#02 pc 000632c1 /system/lib/libdvm.so
#03 pc 00053b7f /system/lib/libdvm.so
#04 pc 00012d70 /system/lib/libc.so (__thread_entry+48)
#05 pc 000124c8 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
"Signal Catcher" daemon prio=5 tid=3 RUNNABLE
| group="system" sCount=0 dsCount=0 obj=0x41e1ecb8 self=0x41368f10
| sysTid=14023 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1523976200
| schedstat=( 22277832 1953124 11 ) utm=1 stm=1 core=1
at dalvik.system.NativeStart.run(Native Method)
"GC" daemon prio=5 tid=2 VMWAIT
| group="system" sCount=1 dsCount=0 obj=0x41e1ebd8 self=0x41367930
| sysTid=14021 nice=0 sched=0/0 cgrp=[no-cpu-subsys] handle=1479362424
| schedstat=( 63446045 39611816 26 ) utm=6 stm=0 core=1
#00 pc 0000dc80 /system/lib/libc.so (__futex_syscall3+8)
#01 pc 00012db4 /system/lib/libc.so (__pthread_cond_timedwait_relative+48)
#02 pc 00012e10 /system/lib/libc.so (__pthread_cond_timedwait+60)
#03 pc 0006e64b /system/lib/libdvm.so
#04 pc 00053b7f /system/lib/libdvm.so
#05 pc 00012d70 /system/lib/libc.so (__thread_entry+48)
#06 pc 000124c8 /system/lib/libc.so (pthread_create+172)
at dalvik.system.NativeStart.run(Native Method)
----- end 14019 -----
有什么想法吗?
答案 0 :(得分:4)
我有同样的问题。
我正在使用com.google.android.gms:play-services:7.5.0
到目前为止,我发现的唯一“解决方案”是禁用跟踪器上的异常报告功能:
applicationTracker.enableExceptionReporting(false);
看起来,Google Analytics会在尝试举报未捕获的异常时导致死锁。
一旦您停用了异常报告,基础异常就会显示并崩溃您的应用,但至少您可以识别并修复它......
希望这会有所帮助,直到Google解决此问题。