3
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?

Bo Persson
  • 90,663
  • 31
  • 146
  • 203
android_su
  • 1,637
  • 4
  • 21
  • 30

3 Answers3

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.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117
  • 1
    I'm sorry.I'm not good at English.What does "stock 'su' tool" mean?And how can I get a customized one? – android_su Jul 06 '12 at 04:15
  • 2
    @JoxTraex if adb is running as root as the posted message indicates, the phone is rooted (ie, the user can run arbitrary code as root). What remains is simply a question of configuring it as desired. – Chris Stratton Jul 06 '12 at 04:40
  • @android_test - you are going to have to decide for yourself what, if indeed any, unofficial tool you want to trust. Part of that consideration would be why you need root. – Chris Stratton Jul 06 '12 at 04:43
  • @Chris Stratton just a test.so, unofficial tool is ok.But I still confused that why I can't execute 'su' now?Why do I have to need and other tools? – android_su Jul 06 '12 at 05:07
  • Because the su tool on some android official versions was not meant to be usable by 3rd party developers or end users. – Chris Stratton Jul 06 '12 at 06:07
  • @ChrisStratton I'm faced with the same problem. How can I go about replacing the stock su binary with ADB? https://android.stackexchange.com/questions/174697/how-to-full-root-a-stock-root-only-android-device – PrashanD May 12 '17 at 09:31
0

If you are being denied root by the system, there is not much you can do aside from rooting the device.

JoxTraex
  • 13,423
  • 6
  • 32
  • 45
0

Perhaps you should try How to get root access and execute.

Parth Doshi
  • 4,200
  • 15
  • 79
  • 129