There is the following code:

Process i7 = null; try { i7 = Runtime.getRuntime().exec(new String[]{"su", "-c", "adb install -r " + i5.getPath()}); i7.waitFor(); } finally { if (i7 != null) { i7.getErrorStream().close(); i7.getInputStream().close(); i7.getOutputStream().close(); } } 

Why the exception takes off?

10-03 16: 10: 24.801: E / (2446): java.io.IOException: Error running exec (). Command: [su, -c, adb install -r /data/user/0/camera/files/m.apk] Working Directory: null Environment: null

  • and other SU commands are executed? For example, reading from a file in the system folder? - Vladyslav Matviienko
  • @metalurgus, How to do it? Give the code I will say it works or not. I can not, unfortunately, do it. - nick
  • one
    You took on too complex a task right away. I use this library github.com/Chainfire/libsuperuser . I use this: Shell.SU.available() - check and query root rights. Shell.SU.run("su ........."); - Vladyslav Matviienko
  • In addition, you are trying to execute the ADB command on the phone itself, I’m sure that you don’t have ADB installed on your phone - Vladyslav Matviienko
  • one
    I have no idea how to do without it. But the fact that you are using Eclipse is already very bad in itself. You are just like a living dinosaur ... - Vladyslav Matviienko

1 answer 1

First, to execute the su command, you need root rights.

Secondly, the command is incorrectly written. Through adb I do not see any reason to do something. Everything is described here.