11

The environments: windows 10(home, pro), visual studio 2015(community, professional) all combination.

Start visual studio 2015 update 1, new project, Native-Activity Application(Android), thus make default android native app. Build solution and start debugging. Then such error message is presented:

Error message.

Unable to start debugging. Android command 'run-as' failed. Package 'com.Android1' is unknown.

I googled, but cannot find how to solve. What I missed? How to set up my environments, or fix something?

Mad Physicist
  • 107,652
  • 25
  • 181
  • 264
JinMin Choi
  • 111
  • 1
  • 5

3 Answers3

3

The solution to this is that you must root your device and fix a file permission. You can try following the advice on the prompt (especially if rooting is not an option) but in some cases only a root will fix the issue.

Once you have rooted your device open an adb shell and run the following:

su
mount -o remount,rw /system
chmod 4750 /system/bin/run-as
mount -o remount,ro /system

This fixes the setuid permission so that the run-as process is granted access based on the owner of the file (i.e. root).

James Oltmans
  • 1,057
  • 13
  • 26
  • 1
    If you have **root**, you don't need **run-as**, do you...? – rustyx Oct 29 '17 at 18:23
  • but non-root things like visual studio and delphi, which use run-as (via adb) to attach their gdb debug sessions, do need it. – Warren P May 08 '18 at 17:06
  • I had the same problem on my Samsung J1 (SM-J100H). Tried everything! The only way was to root the device and to use those 3 lines above. Thank you James! – Gediminas Jun 01 '20 at 11:17
2

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.

Giedrius
  • 73
  • 1
  • 6
  • Had the same issue on Samsung Galaxy S7 edge, i reset my device via Samsung's Smart Switch (installed it on mac) and run-as command works now. – Kavitha May 23 '17 at 16:26
  • How do you reset the device with Smart switch? – Vincy Jul 20 '17 at 15:52
  • A little more detail than a link to the page where you are shown some vague information about how to copy data from your old sammy phone to your new one, please? – Warren P May 08 '18 at 17:08
  • In the Smart Switch software, there was an option to 'initialize' the device in one of the sub-menus, hopefully this option is still available in the latest software version - I didn't need to use the software anymore after resolving this issue on my phone. – Giedrius May 09 '18 at 12:42
  • My Samsung S5 debugged fine, my new S8 not, I see reports here of S6 and S7 being problematic. I have tried all the workarounds, nothing has helped my S8. Does anyone know if the problem still continues with the S9? I'm definitely going to be trying to look for a device that does not have this issue at all when my contract becomes due again. – Maya Jul 28 '18 at 09:00
0

Down load it from Samsung, kies. You will see an option to download the smart switch Click the link in the previous answer...

user941089
  • 74
  • 1
  • 5