run-as: Could not set capabilities: Operation not permitted
Asked Answered
W

10

61

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 ?

Whatsoever answered 24/5, 2016 at 12:31 Comment(1)
According to this, this is a bug on Samsung devices: code.google.com/p/android/issues/detail?id=206581#c4Saponin
U
81

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.

Unmoral answered 29/10, 2017 at 19:45 Comment(5)
Thanks, you are a life saver. But zlib didn't work on my Mac, so I had to use the abe.jar for extraction. See my answer https://mcmap.net/q/102912/-how-can-one-pull-the-private-data-of-one-39-s-own-android-appOstracoderm
@Ostracoderm As pointed here on mac you can do the following command : dd if=data.ab bs=24 skip=1 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" > data.tarAnsley
This worked for me. Since I'm using Windows, I had to install Cygwin and copy your commands into a .sh and run the .sh. And it worked flawlessly. Thanks.Watteau
i am getting dd is not recognized as internal or external commandPaving
Based on this comment, after I uninstalled my application from Samsung device, Visual Studio failed to reinstall and debug, so I ran adb uninstall com.companyname.packagename. Now I am able to debug again.Manriquez
O
14

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

Orientalism answered 21/8, 2021 at 12:13 Comment(3)
Didn't see the line within the Android .csproj file but added the 'true' line and it worked for my Samsung s5. Thank you!Iver
Pleasure is all mine !Orientalism
Just Experience on MAUI .NET CORE 6 w/ VS2022, using Samsung T-810 tablet to debug my project , I comfirm this solution is works perfectly!Explore
B
3

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

Backset answered 6/11, 2017 at 15:3 Comment(1)
Confirmed. -autolaunch in the run->parameters, worked for me from Delphi 10.1.2 with my Samsung A7 (2017).Belier
O
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: https://www.youtube.com/watch?v=Sy4FWLHxGYs

and then from here: https://www.tomsguide.com/us/samsung-galaxy-s6-guide,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:

https://issuetracker.google.com/issues/37093233#comment53

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.

Obligee answered 8/10, 2017 at 11:30 Comment(0)
T
1

I was working from Delphi 10.1 berlin. I was presented with the same problem and my solution was to configure the sdk to the previous version. I was using Android SDK 25.2.5.32bit and downgraded to android SDK 24.3.3 32 bit. To configure:

Tools->Environment Options -> SDK Manager

Then, add the necessary sdk, in this case android SDK 24.3.3 32 bit.

Trifoliate answered 16/1, 2019 at 20:15 Comment(2)
Welcome to Stack Overflow. Please write your answer in English, as Stack Overflow is an English only site.Johannejohannes
@Daniel for future reference, do not translate posts for OP; even if you know the languageJohannejohannes
A
1

Here is solution for MS Visual Studio 2022.

https://www.youtube.com/watch?v=_r9GLm0k55o

enter image description here

Just uncheck the "Use Fast Deployment".

Awlwort answered 12/5, 2022 at 1:27 Comment(0)
O
0

@RustyX answer helped my partially. zlib didn't work in my Mac. So I had to use the Android Backup Extractor to convert .ab file to .tar file. You can download it here.

For the full step by step instruction, refer here.

Ostracoderm answered 3/1, 2018 at 12:7 Comment(0)
G
0

In Visual Studio, App properties, Android Options, changing the debugger from C++ to .Net(Xamarin) seems to have fixed the problem for a mixed C++/C# app.

Geanine answered 6/6, 2018 at 9:3 Comment(0)
V
0

Also got this error today when I tried to deploy/debug my application on a Samsung Xcover 3 running Android 6. I solved it by changing the project property "Android Options / Use Fast Deployment" to false.

Vacuity answered 26/4, 2022 at 7:34 Comment(0)
S
-1

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 https://mcmap.net/q/102914/-visual-studio-2015-android-command-39-run-as-39-failed:

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.

Streaky answered 3/7, 2017 at 8:41 Comment(6)
Can you explain what do you mean by "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." I have installed the Samsung's Smart Switch but don't even see the option to factory resetting in there and it looks like just to transfer the file from one device to another...Lan
Open Smart Switch, click "More" and choose "Emergency software recovery and initialization"Streaky
Tried to perform hard reset, spent 30 min - 1 hour, but problem is still there. May I ask you if you have tried this by yourself ?Obligee
I solved the issue on my own device using the steps I posted above. What do you mean exactly by hard reset? Hard reset has a different meaning than factory reset and initialization.Streaky
Did not work for Galaxy S7. Smart Switch says "SM-G930A does not support initializing."Hush
Looks like there are a lot of different device models. The instructions I posted here worked on my Samsung Galaxy S6 Edge, SM-G925F. The advantage of this method I posted is that you don't need to root your device. If the instructions didn't work, try updating the OS to a later build. The OS build number that works for me right now is NRD90M.G925FXXU5EQBCStreaky

© 2022 - 2024 — McMap. All rights reserved.