How can I execute “su” on Android?

孤街醉人 提交于 2020-01-04 02:03:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!