Traceview cannot record SD card

I am adding a tracking code as shown below:

Debug.startMethodTracing("perf_trance"); //code Debug.stopMethodTracing(); 

And then I set the required permission in the manifest.

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

but when I run the application to track performance, I got below RuntimeException:

 06-04 14:57:23.083: E/AndroidRuntime(5584): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myxx.testapp/com.myxx.testapp.MainActivity}: java.lang.RuntimeException: Unable to open trace file '/mnt/sdcard/perf_trance.trace': Permission denied 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2007) 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2034) 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.app.ActivityThread.access$600(ActivityThread.java:129) 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1185) 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.os.Handler.dispatchMessage(SourceFile:99) 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.os.Looper.loop(SourceFile:137) 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.app.ActivityThread.main(ActivityThread.java:4518) 06-04 14:57:23.083: E/AndroidRuntime(5584): at java.lang.reflect.Method.invokeNative(Native Method) 06-04 14:57:23.083: E/AndroidRuntime(5584): at java.lang.reflect.Method.invoke(Method.java:511) 06-04 14:57:23.083: E/AndroidRuntime(5584): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(SourceFile:809) 06-04 14:57:23.083: E/AndroidRuntime(5584): at com.android.internal.os.ZygoteInit.main(SourceFile:576) 06-04 14:57:23.083: E/AndroidRuntime(5584): at dalvik.system.NativeStart.main(Native Method) 06-04 14:57:23.083: E/AndroidRuntime(5584): Caused by: java.lang.RuntimeException: Unable to open trace file '/mnt/sdcard/perf_trance.trace': Permission denied 06-04 14:57:23.083: E/AndroidRuntime(5584): at dalvik.system.VMDebug.startMethodTracingNative(Native Method) 06-04 14:57:23.083: E/AndroidRuntime(5584): at dalvik.system.VMDebug.startMethodTracing(VMDebug.java:175) 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.os.Debug.startMethodTracing(SourceFile:496) 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.os.Debug.startMethodTracing(SourceFile:444) 06-04 14:57:23.083: E/AndroidRuntime(5584): at com.mediatek.oobe.basic.MainActivity.onCreate(MainActivity.java:154) 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.app.Activity.performCreate(Activity.java:4479) 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050) 06-04 14:57:23.083: E/AndroidRuntime(5584): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1971) 06-04 14:57:23.083: E/AndroidRuntime(5584): ... 11 

I do not know why traceview cannot write to / mnt / sdcard /?

I also note that directory resolution is d --- rwxr-x, is this the main reason?

+4
source share

All Articles