当我使用这段代码时:

process = Runtime.getRuntime().exec("su");

os = new DataOutputStream(process.getOutputStream());

总有一个错误,任何想法?在Android虚拟设备上运行

W/System.err(3211): java.io.IOException: Error running exec(). Command: [su] Working Directory: null Environment: null

W/System.err(3211): at java.lang.ProcessManager.exec(ProcessManager.java:211)

W/System.err(3211): at java.lang.Runtime.exec(Runtime.java:174)

W/System.err(3211): at java.lang.Runtime.exec(Runtime.java:247)

W/System.err(3211): at java.lang.Runtime.exec(Runtime.java:190)

W/System.err(3211): at com.example.executeandroidtest.ShellUtils.execCommand(MainActivity.java:661)

W/System.err(3211): at com.example.executeandroidtest.MainActivity$3.run(MainActivity.java:410)

W/System.err(3211): at java.lang.Thread.run(Thread.java:818)

W/System.err(3211): Caused by: java.io.IOException: Permission denied

W/System.err(3211): at java.lang.ProcessManager.exec(Native Method)

W/System.err(3211): at java.lang.ProcessManager.exec(ProcessManager.java:209)

W/System.err(3211): ... 6 more

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐