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 ?


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

Instead of dd you can use the abe tool, which can also write .ab files.


For me, it went like this. I am using Samsung s6 API 24. The error list log's detail was the same as mentioned in the question. But when I checked the Build Logs I found the solution written there. To set the MSBuild. So I followed the following steps to resolve this and the app ran successfully. To correct this problem I had to

Unload Android Project from solution explorer Right-Click unloaded project and "Edit Project File" Searched code for "EmbedAssembliesIntoApk" Found the occurrence in the project file

<EmbedAssembliesIntoApk>false</EmbedAssembliesIntoApk>

Change it to true and reload the project.

<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>

Ran the app and the app starts running on Samsung s6