问题
process = Runtime.getRuntime().exec("su");
os = new DataOutputStream(process.getOutputStream());
os.writeBytes(command + "\n");
os.writeBytes("exit\n");
os.flush();
process.waitFor();
The system says:"07-06 11:01:34.337: I/System.out(3864): su: uid 10170 not allowed to su"
I execute "adb root" in my terminal
:~/android/android-sdk/platform-tools$ ./adb root
adbd is already running as root
Any ideas?
回答1:
It looks like your adb is running as root, but you only have the stock 'su' tool. You could use adb to replace it with a customized one of your choice.
Either that, or you do have a customized one and it's been configured not to allow this application userid you are running under - in that case, you need to open its configuration tool and change this.
Please note - this is an old answer to an old question - it's been several Android versions since a conventional su
stopped being possible on typical end-user Android builds due to the SELinux adoption. Workarounds are far beyond the scope of this question.
回答2:
If you are being denied root by the system, there is not much you can do aside from rooting the device.
回答3:
Perhaps you should try How to get root access and execute.
来源:https://stackoverflow.com/questions/11355480/how-can-i-execute-su-on-android