Chris
Chris

Reputation: 683

Permission denied message on Android method tracing

I'm trying to follow these steps to help figure out where my first Android app (using Android Studio, targeting a Nexus 9) is crashing:

http://developer.android.com/tools/debugging/debugging-tracing.html

I added Debug.startMethodTracing and Debug.stopMethodTracing to my main activity code in the recommended places. When I actually debug my code I get the following message in my "logcat" window.

02-17 11:40:34.418  15711-15711/com.mpr.myfirstapp E/art﹕ Unable to open trace file '/storage/emulated/legacy/seemore.trace': Permission denied

I'm not sure why this is, and I'm also not sure how in Android Studio to view the trace logs. Can anyone help?

NOTE: It seems worth noting that (from the link)

Android 2.2 and later devices do not need an SD card. The trace log files are streamed directly to your development machine.

So I'm not sure if the permission issue is on my dev machine or on the device.

Thanks for any help.

Upvotes: 2

Views: 1258

Answers (1)

charliebeckwith
charliebeckwith

Reputation: 1449

You can use the Android Device Monitor to trace from your dev machine.

Try adding these to your AndroidManifest.xml and let me know if the error is still there.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

Then in terminal you want to run (if you're on PC the command would be different but similar)

adb pull /sdcard/seemore.trace ~/tmp

Then open up Android Device Monitor and open up the file, now located in

~/tmp/seemore.trace

you can start the Android Device Monitor using the command

./monitor

Upvotes: 2

Related Questions