Splunk MINT SDK for Android

Splunk MINT SDK for Android Developer Guide

Download manual as PDF

Download topic as PDF

Report ANRs

When mobile apps become non-responsive and cannot respond to user input, Android devices display an Application Not Responding dialog box, or ANR, which forcefully terminates the non-responding app. The timeout is enforced by the system. You can view a report of ANRs when they occur in your mobile app. This monitoring feature helps you to identify common problem of ANR, such as application deadlocks and unexpectedly long-running or stalled HTTP requests.

Enable ANR reporting using the following startANRMonitoring(timeout, ignoreDebugger) method. For example:

Mint.startANRMonitoring(5000, true);

Then, when an ANR occurs, a normal handled exception is created containing an ANR parameter set to "true" in extraData. To find these occurrences, run a search in Splunk Web. For example:

sourcetype="mint:error" "extraData.ANR"=true

Inspect the stacktrace.0 field in the search results. This field contains a list of app threads and the corresponding stacks at the time the ANR occurred. Note that the "Caused by" line is used as a delimiter, and does not indicate the cause of the precedent exception.

Here is an example result:

 { [-]
   apiKey: fbcc7783
   appEnvironment: Release
   appVersionCode: 1
   appVersionName: 1.0
   batteryLevel: 17
   breadcrumbs: [
   ]
   carrier: Android
   connection: NA
   currentView: NA
   device: Genymotion Google Nexus 6 - 6.0.0 - API 23 - 1440x2560
   errorHash: 46b69b11185d8288c0b2737d47ec9414
   extraData: { [-]
     ANR: true
   }
   gpsStatus: NA
   handled: true
   klass: java.lang.Exception
   locale: US
   log: NA
   memAppAvailable: 0.21
   memAppMax: 96
   memAppTotal: 2.23
   memSysLow: false
   memSysThreshold: 0
   message: java.lang.Exception: com.github.anrwatchdog.ANRError: Application Not Responding
   msFromStart: 6006
   osVersion: 6.0
   packageName: com.splunk.mint.test.testanr
   platform: Android
   remoteIP: 204.107.141.240
   rooted: true
   screenOrientation: Portrait
   sdkVersion: 5.1.0
   session_id: 12443316-1d22-4428-a4f0-d4084440fe07
   stacktrace: { [-]
     0: java.lang.Exception: com.github.anrwatchdog.ANRError: Application Not Responding
	at com.splunk.mint.Mint$3.onAppNotResponding(Unknown Source)
	at com.github.anrwatchdog.ANRWatchDog.run(Unknown Source)
Caused by: com.github.anrwatchdog.ANRError: Application Not Responding
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: main
	at java.lang.Thread.sleep(Native Method)
	at java.lang.Thread.sleep(Thread.java:1031)
	at java.lang.Thread.sleep(Thread.java:985)
	at android.os.SystemClock.sleep(SystemClock.java:120)
	at com.splunk.mint.test.testanr.MainActivity.StopResponding(MainActivity.java:23)
	at java.lang.reflect.Method.invoke(Native Method)
	at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
	at android.view.View.performClick(View.java:5198)
	at com.splunk.mint.test.testanr.ApplicationTest.testANR(ApplicationTest.java:43)
	at java.lang.reflect.Method.invoke(Native Method)
	at android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
	at android.test.InstrumentationTestCase.-wrap0(InstrumentationTestCase.java)
	at android.test.InstrumentationTestCase$2.run(InstrumentationTestCase.java:189)
	at android.app.Instrumentation$SyncRunnable.run(Instrumentation.java:1897)
	at android.os.Handler.handleCallback(Handler.java:739)
	at android.os.Handler.dispatchMessage(Handler.java:95)
	at android.os.Looper.loop(Looper.java:148)
	at android.app.ActivityThread.main(ActivityThread.java:5417)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: FinalizerDaemon
	at java.lang.Object.wait(Native Method)
	at java.lang.Object.wait(Object.java:423)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:101)
	at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:72)
	at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:185)
	at java.lang.Thread.run(Thread.java:818)
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: FinalizerWatchdogDaemon
	at java.lang.Thread.sleep(Native Method)
	at java.lang.Thread.sleep(Thread.java:1031)
	at java.lang.Thread.sleep(Thread.java:985)
	at java.lang.Daemons$FinalizerWatchdogDaemon.sleepFor(Daemons.java:273)
	at java.lang.Daemons$FinalizerWatchdogDaemon.waitForFinalization(Daemons.java:284)
	at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:232)
	... 1 more
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: HeapTaskDaemon
	at dalvik.system.VMRuntime.runHeapTasks(Native Method)
	at java.lang.Daemons$HeapTaskDaemon.run(Daemons.java:355)
	... 1 more
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: Instr: android.support.test.runner.AndroidJUnitRunner
	at java.lang.Object.wait(Native Method)
	at android.app.Instrumentation$SyncRunnable.waitForComplete(Instrumentation.java:1908)
	at android.app.Instrumentation.runOnMainSync(Instrumentation.java:353)
	at android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:186)
	at android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTestCase2.java:192)
	at junit.framework.TestCase.runBare(TestCase.java:134)
	at junit.framework.TestResult$1.protect(TestResult.java:115)
	at android.support.test.internal.runner.junit3.AndroidTestResult.runProtected(AndroidTestResult.java:77)
	at junit.framework.TestResult.run(TestResult.java:118)
	at android.support.test.internal.runner.junit3.AndroidTestResult.run(AndroidTestResult.java:55)
	at junit.framework.TestCase.run(TestCase.java:124)
	at android.support.test.internal.runner.junit3.NonLeakyTestSuite$NonLeakyTest.run(NonLeakyTestSuite.java:63)
	at junit.framework.TestSuite.runTest(TestSuite.java:243)
	at junit.framework.TestSuite.run(TestSuite.java:238)
	at android.support.test.internal.runner.junit3.DelegatingTestSuite.run(DelegatingTestSuite.java:103)
	at android.support.test.internal.runner.junit3.AndroidTestSuite.run(AndroidTestSuite.java:69)
	at android.support.test.internal.runner.junit3.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
	at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:54)
	at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:240)
	at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1879)
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: OkHttp ConnectionPool
	at java.lang.Object.wait(Native Method)
	at com.android.okhttp.ConnectionPool.performCleanup(ConnectionPool.java:305)
	at com.android.okhttp.ConnectionPool.runCleanupUntilPoolIsEmpty(ConnectionPool.java:242)
	at com.android.okhttp.ConnectionPool.-wrap0(ConnectionPool.java)
	at com.android.okhttp.ConnectionPool$1.run(ConnectionPool.java:97)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
	at java.lang.Thread.run(Thread.java:818)
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: Okio Watchdog
	at java.lang.Object.wait(Native Method)
	at com.android.okhttp.okio.AsyncTimeout.awaitTimeout(AsyncTimeout.java:323)
	at com.android.okhttp.okio.AsyncTimeout.-wrap0(AsyncTimeout.java)
	at com.android.okhttp.okio.AsyncTimeout$Watchdog.run(AsyncTimeout.java:286)
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: ReferenceQueueDaemon
	at java.lang.Object.wait(Native Method)
	at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:147)
	at java.lang.Thread.run(Thread.java:818)
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: Thread-154
	at java.lang.Object.wait(Native Method)
	at java.lang.Thread.parkFor$(Thread.java:1220)
	at sun.misc.Unsafe.park(Unsafe.java:299)
	at java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
	at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2013)
	at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:410)
	at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1038)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1098)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
	... 1 more
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: Thread-158
	... 10 more
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: Thread-159
	... 10 more
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: pool-2-thread-1
	... 10 more
Caused by: com.github.anrwatchdog.ANRError$$$_Thread: |ANR-WatchDog|
	at dalvik.system.VMStack.getThreadStackTrace(Native Method)
	at java.lang.Thread.getStackTrace(Thread.java:580)
	at java.lang.Thread.getAllStackTraces(Thread.java:522)
	at com.github.anrwatchdog.ANRError.New(Unknown Source)
	at com.github.anrwatchdog.ANRWatchDog.run(Unknown Source)
   }
   state: NA
   threadCrashed: 0
   transactions: [
   ]
   userIdentifier: NA
   uuid: fake_uid
   where: Unknown Source
} 
PREVIOUS
Report handled exceptions
  NEXT
Add custom data to crash reports

This documentation applies to the following versions of Splunk MINT SDK for Android: 5.2.x


Was this documentation topic helpful?

Enter your email address, and someone from the documentation team will respond to you:

Please provide your comments here. Ask a question or make a suggestion.

You must be logged into splunk.com in order to post comments. Log in now.

Please try to keep this discussion focused on the content covered in this documentation topic. If you have a more general question about Splunk functionality or are experiencing a difficulty with Splunk, consider posting a question to Splunkbase Answers.

0 out of 1000 Characters