How to use startMethodTracing APIs on Android?

I recently started work on an application that has both Java and native components. I am trying to generate trace information for both using Debug.startMethodTracing("myapp")and Debug.startNativeTracing()alternately. However, both behave unexpectedly.

When I use Debug.startMethodTracing("myapp"), I can create the created file /sdcard/myapp.trace, but it is always empty, no matter how long I run my application. When I use Debug.startNativeTracing()and start the emulator using the switch -trace <tracename>, I see the message "Trace start", but when I try to start my application, the emulator crashes.

Did I miss something obvious here? How to debug this problem?

+5
source share
1 answer

When this happened to me, it was because I had uncoordinated start / stop pairs. For example, if you start a method trace but never stop, I think that Android just does not write information about the buffered trace to a file. Similarly, if you have an extra stop in the middle or never starts, etc., you will not get the desired results.

Other than this method trace, I worked perfectly.

Native tracing, on the other hand, does not seem to be supported (as before), since I get the error "Qemu trace files are not yet supported" when I try to load my own trace results in traceview. (Comment on this from Google?)

  • Kris
+5
source

All Articles