title: Android Java su command permission denied
body: <p>I was having some problem when trying to use adb install command to install/update APK silently. I am referring to <a href="https://stackoverflow.com/questions/26926274/install-android-apk-without-prompt?utm_medium=organic&amp;utm_source=google_rich_qa&amp;utm_campaign=google_rich_qa">this thread</a>.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public boolean installApk(Activity mActivity){
      boolean success = false;
      String fullPath = scanDirectoryForApk();
      try {
          String command;
          command = "adb install -r " + fullPath;
          Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command });
          proc.waitFor();
          success = true;
      } catch (Exception e) {
          e.printStackTrace();
      }
  }
  </code></pre>
  
  <p>And in my AndroidManifest.xml:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.INSTALL_PACKAGES"/&gt;
  &lt;uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS"/&gt;
  &lt;uses-permission android:name="android.permission.REBOOT" /&gt;
  </code></pre>
  
  <p>The logcat as such:</p>
  
  <pre><code>java.io.IOException: Cannot run program "su": error=13, Permission denied
  06-08 03:46:37.612 5438-5905/com.mainapp W/System.err:     at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
      at java.lang.Runtime.exec(Runtime.java:692)
      at java.lang.Runtime.exec(Runtime.java:560)
      at com.thermofisher.viewmodel.vuViewModel.installApk(vuViewModel.java:281)
      at com.mainapp.asynctask.evuTask.doInBackground(evuTask.java:67)
  06-08 03:46:37.614 5438-5905/com.mainapp W/System.err:     at com.mainapp.asynctask.evuTask.doInBackground(evuTask.java:17)
      at android.os.AsyncTask$2.call(AsyncTask.java:333)
      at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  06-08 03:46:37.615 5438-5905/com.mainapp W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:245)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
      at java.lang.Thread.run(Thread.java:764)
  </code></pre>
  
  <p>I am running the application using Android Emulator. When I am running the emulator I already set the command to make it become rooted.</p>
  
  <p>Any ideas? Thanks!</p>