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
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
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.
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.
#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.
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.
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.
Here is solution for MS Visual Studio 2022.
https://www.youtube.com/watch?v=_r9GLm0k55o
Just uncheck the "Use Fast Deployment".
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://stackoverflow.com/a/43242739/7823460:
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.
This is in the border of programming, so please delete the question if it's not correct posting it.
Question is regarding the Android 5.0 Lollipop.
Basically I've installed the "Messaging" app (com.android.mms) from inside another program (hide it pro). It's an older version of the android messaging. Then my Samsung s5 broke and I had to restore all apps into another similar Samsung. When trying to install the messaging app again (from inside or outside hide it pro) it fails with the error -505. Searching on the net I ended up by installing the android sdk and use adb to see if I could solve the issue. No luck: if I try to uninstall the app (which doesn't exist on the new phone) I get the error DELETE_FAILED_INTERNAL_ERROR.
$ adb uninstall /c/mfg/sms.apk
* daemon not running. starting it now o
* daemon started successfully *
Failure [DELETE_FAILED_INTERNAL_ERROR]
If I try to install the app via adb I get the following result:
$ adb install /c/mfg/sms.apk
3439 KB/s (2078237 bytes in 0.590s)
pkg: /data/local/tmp/sms.apk
Failure [INSTALL_FAILED_DUPLICATE_PERMISSION
perm=android.permission.MMS_SEND_OUTBOX_MSG pkg=com.android.mms]
I don't have the application on the phone, I can't put it to work and I can't get rid of the permissions. There's no way to uninstall on the phone since the app is not there and it won't let itself be installed. It doesn't appear on the Application Manager under "downloaded" or anywhere else.
My question is: is there no way to wipe out the permissions WITHOUT having the application? What I wanted was an app that allowed me to delete the permissions, regardless of having the app or not. The phone is not rooted at the moment but if needed I can root it to solve the issue if it helps. Please advise.
So I've finally found the issue. Thanks Manish and iagocanalejas for the suggestions.
It seems that something changed on the permissions system on android 5.0 (as part of one of the updates). It didn't happen before, but now if two packages from different applications ask for the same permission (in this case android.permission.MMS_SEND_OUTBOX_MSG pkg=com.android.mms), it won't let the second application install.
This behavior is new and didn't happen on previous versions of Lollipop. Flashing a newer version of the OS on my phone clearly didn't solve the issue (original was G900FXXU1BNL9 and I've finished with G900FXXU1BOD3). If anything, only made it worse since this behavior seems to have come to stay.
The solution was to root the phone, install Titanium Backup, and (after backing up everything) REMOVING with help of Titanium Backup the "Messages" application which on the Samsung replaces the standard "Messaging" android app.
Titanium backup was needed because "Messages" is considered as a system application and therefore couldn't be removed normally. No SMS messages were lost by removing "Messages". It was necessary to reboot the phone after removing "Messages" so that "Messaging" could be installed, but finally, after 2 weeks of effort, it could be done.
Have you tried to uninstall using application package? This should delete any data/cache associated with application.
$ adb uninstall com.android.mms
Install the application after this as usual:
$ adb install /c/mfg/sms.apk
Take a look on your manifest and see if u have duplicated rows
I trying to use libusb on not rooted Nexus 5 as advised in this approach (by transferring usb file descriptor from java to native side).
My application ask permission via UsbManager.requestPermission and then run native method that call libusb_init to create libusb_context.
But libusb_init returns LIBUSB_ERROR_OTHER code (-99). After digging in the code I see why this happening. libusb reports 'could not find usbfs' because opendir("/dev/bus/usb") returns 0.
Also from adb shell I can't perform ls /dev, strange because I have rights (on Huawei U8950-1 with the same rights I can do this):
drwxr-xr-x root root 2014-09-04 10:26 dev
Looks like approach described below work not for all android devices. Can someone explain why?
There is already a fix in this libusb fork:
https://github.com/martinmarinov/rtl_tcp_andro-
Now, not only you will need to pass the file descriptor, you will need to pass the device file path as well via UsbDevice.getDeviceName().
Looks like Android L have an additional restriction about accessing to /dev deirectory. I have no more ideas about this
Update
Security Enhancements in Android 5.0
...
Android sandbox reinforced with SELinux. Android now requires SELinux in enforcing mode for all domains. SELinux is a mandatory access control (MAC) system in the Linux kernel used to augment the existing [discretionary access control (DAC) security] model](http://en.wikipedia.org/wiki/Discretionary_access_control). This new layer provides additional protection against potential security vulnerabilities.
...
Workarounds
Install SELinuxModeChanger and change SELinux mode to permissive
https://github.com/Gritzman/libusb
There is a custom libusb 1.0 which is capable of solving this issue by doing LibusbInit by passing the path of the usb device , this can bypass readdir command http://www.libusb.org/ download from the home webpage itself.
im building new device and have to provide CTS review results,
unfortunately upon running java -cp ddmlib-prebuilt.jar;tradefed-prebuilt.jar;hosttestlib.jar;cts-tradefed.jar -DCTS_ROOT=D:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools\android-cts\tools\cts com.android.cts.tradefed.command.CtsConsole
and then running a list devices command, tradefed returns empty list.
Can anyone advice if there are any hard pre-requisites for execution of tradefed?
Or any other guess as to what exactly may be the problem?
ps. Running a tests leaves immediate empty reply without no error code.
ps2. target is 4.4.4 kitkat
Resolution found, problem was in PATH incorrectly set in windows and in executing command (must lead to main directory of CTS not to tradefed directory)
I have this application which I'm testing. I use a script which automatically installs the app but I also want to restart the device. This is important as after the installation I run a monkey-test on the device and all kind of quirks and bugs may arise. To get rid of these I want to restart the phone to get it into some kind of "known state". (These bugs are not only in the app as the phone has been known to suddenly shutdown during the tests)
My installation script is run with jython and I know of the device.reboot() command but this takes almost no time at all (which makes me suspicious) and doesn't work very well. I know there's three arguments: "bootloader", "recovery" and "None" but I can't find the impact these would have on the device.
So my question is, is device.reboot() the right command to use? If yes, what happens when I don't use any arguments with the device.reboot() command and what is the effects of the arguments.
It may be worth mentioning that I run the jython script from a batch command prompt in jenkins. So any batch commands using adb or similar would work just as fine.
device.reboot("None") works on my device