How to use startMethodTracing APIs on Android?
I have recently started working on an app which has both Java and
native components. I am trying to generate 开发者_如何学JAVAtrace information for both
components using Debug.startMethodTracing("myapp")
and
Debug.startNativeTracing()
alternately. However, both are behaving unexpectedly.
When I use Debug.startMethodTracing("myapp")
, I can see a file /sdcard/myapp.trace
being created but it is always empty no matter how long I run my app. When I use Debug.startNativeTracing()
and start the emulator with the -trace <tracename>
switch, I see a message saying "Trace started", but when I try to run my app, the
emulator crashes.
Am I missing something obvious here? How do I debug this problem?
When I've had that happen to me, it's because I've had mismatched start/stop pairs. For example, if you start method tracing but never stop, I think Android simply never writes the buffered trace information out to a file. Similarly if you have an extra stop in the middle, or never start, etc, you're not going to get the desired results.
Other than that method tracing has worked fine for me.
Native tracing, on the other hand, appears to not be supported (still), since I get an error "Qemu trace files not supported yet" when I try to load the native trace results into traceview. (Any comment on that from Google?)
- Kris
精彩评论