I expect it's permissions-related. A good way is to use run-as
from adb shell
. For example, supposing your application is com.srooth.fancyapp
, do this:
adb shell run-as com.srooth.fancyapp strace -p 20436 -o /mnt/sdcard/sampleTrace11.txt
If this doesn't work, you know it's something to do with the permissions of com.srooth.fancyapp
, and you can expect to get the same result when running from within Java.
Some possible permissions problems:
Your app does not have permission to write to the SD card. This capability will be inherited by all other apps running as your user, so it's important to ensure that your AndroidManifest.xml
specifies the permission:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
If the process in question is not part of your application, it will be run as a different user. As such your application will not have permission to inspect it. There's nothing you can do about this, except for using a rooted phone and prepending su -c
to your command line.
A couple of other ideas: