问题描述:

My UIAutomator testcase requires a file to be copied from sdcard to data/local/tmp and proceed further. When I use the below mentioned code:

public void RunAsRoot(String cmds) throws IOException{

Process p = Runtime.getRuntime().exec("cmds");

}

I get this exception.

java.io.IOException: Error running exec(). Command: [cmds] Working Directory: null Environment: null

at java.lang.ProcessManager.exec(ProcessManager.java:211)

at java.lang.Runtime.exec(Runtime.java:168)

at java.lang.Runtime.exec(Runtime.java:241)

Caused by: java.io.IOException: Permission denied

at java.lang.ProcessManager.exec(Native Method)

at java.lang.ProcessManager.exec(ProcessManager.java:209)

... 20 more

Is there any other way to do the same? I appreciate the answers,

Thanks.

网友答案:

There is a typo in your example. "cmds" instead of cmds. This code is part of an Android app? What kind of commands exactly are you using? Are you launching on a rooted phone or an emulator?

相关阅读:
Top