JavaEar 专注于收集分享传播有价值的技术资料

run-as: Could not set capabilities: Operation not permitted

on android 6.0.1 I am getting this error when trying to use run-as.

⋊> ~ adb shell                                                          14:29:01
shell@trlte:/ $ run-as org.ligi.passandroid                                    
run-as: Could not set capabilities: Operation not permitted

I really like the run-as command - is there a way to get it to work on 6.0.1 ?


  1. Unlike another answer here, I have also tried to use smart switch & hard device resetting, but unfortunately that approach did not work for me (Wasted extra one hour just to try out that approach). Besides not working, it might create additional problem "samsung account: session expired" - problem, which can be fixed only if you have root access to your device.

    I by myself have used instructions from here:

    and then from here:,review-2856-3.html

    for getting root access to your device, and after that run-as can be executed with additional command "su -c" as for get root user. So whole command will look like this:

    su -c run-as org.ligi.passandroid

    WARNING: Gaining root access to your device will most probably void your device warranty if you have any left.

    Additionally to this, I wanted to be able to debug my application inside Samsung Galaxy S6, so I've altered Visual studio components, more instructions can be found here:

    If you happen to have Samsung based android device - I have already reported that bug to Samsung, but I've could not get any time schedule if when and if at all they are going to fix this issue. If you own some other Android device - makes sense to report this problem to manufacturer.

  2. 参考答案2
  3. If you have a SAMSUNG device, don't bother - SAMSUNG broke run-as by dropping the setuid flag (so run-as has no chance of switching to a different identity).

    Also don't bother trying the Smart Switch "reinitialize device" workaround, it won't work until SAMSUNG fixes it in the firmware (so it is worth updating to the latest version).

    Use some other method to access your app's data, like adb backup:

    adb backup -f data.ab <my.package>
    dd if=data.ab  bs=24 skip=1 | openssl zlib -d > data.tar
  4. 参考答案3
  5. The solution for me was the parameter -autolaunch in the Debugger configuration of the project in the field Parameters.

    I use Delphi 10.2 with S7 Edge Android 7

  6. 参考答案4
  7. I had previously posted an answer here which was deleted, maybe because it was a link to another stackoverflow question referring to the answer I gave there, instead of containing the full answer.

    Reposting its contents here from

    I had a very similar issue on Samsung Galaxy S6 Edge, trying to start debugging on VS2015, I got a different error, much less verbose than in the attached screenshot:

    run-as: Could not set capabilities: Operation not permitted

    Based on the contents of the attached screenshot above, I tried 'initializing' / factory resetting the device using Samsung's Smart Switch and it actually fixed the 'run-as' issue I was having.

    This is the only solution which worked and didn't involve rooting the device, so I believe it must be publicly available. Of course people attempting this should keep in mind that factory reset means that data will be lost, unless it's backed up. The same Samsung software helps with backing up your data.