When I use this code:
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
there is always an error, any ideas? Running on an android virtual device
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
Caused by: java.io.IOException: Permission denied
/system/xbin/su
ls -al /system/xbin/su
chmod 4755 su
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With