Question

while i add this line to my code

Process process = Runtime.getRuntime().exec("su -c");

or

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

trying to run the"su" command,

process.exitValue() returns 1 which means fail.

This happens to my one Android device while my the other rooted android device works perfectly with this command. (process.exitValue() returns 0)

Can anyone teach me how to trace the error or how to fix it?

I am confused with this error while my two devices almost in the same condition.

Thanks for your reply in advance.


Hi guys,

Thanks for discussing this issue with me. Your reply hints me a clue that I have removed my old su and place a new su. Luckily enough, the return value is now 0 and I guess it means correct. However, Does any of you might know what is the difference between .exec("su -c") and .exec("su")? Please let me know if you know the difference.

Était-ce utile?

La solution

I suspect you lack Superuser on the problematic phone, do you? Or at least something about Superuser could be wrong (versions, binaries...)

su calls Superuser which allows root access or not.

Many problems seems to occurs on latest versions of Superuser.

Try to remove it and install other version:

http://goo.im/superuser

Another note: if you're trying to gain root access or to execute commands as root, you should not only use exec("su"). Take a look at the RootTools a library by stericson himself ;)

http://code.google.com/p/roottools/

Autres conseils

The command su (which means Super User) is only valid on rooted phones. That is why your rooted phone recognizes it and works as expected. So, either you root your other device(s) or drop this idea on non-rooted phones :)

Since this is the only result I got for searching for the phrase, thought I'd post an update for anyone else coming across this.

Was following the instructions for installing Cyanogenmod. My issue was resolved by disabling Mass Storage mode on the device (change it to one of the other options).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top