While trying to use Visual Studio 2015 (community edition) to compile and run a simple Android app (the Hello World example you get when you create a new empty Android project in fact) I ran into the apparently well known problem that "run-as" does not work on some Android devices. In fact it does not work on any of those I tried running different versions of KitKat and Lollipop.
After successfully deploying the app, Visual Studio 2015 reports "Unable to start debugging. Android command "run-as" failed. Package com.Android1 is unknown"
I do not want to root the device to change the packages.list attributes, but I can successfully use "am start com.Android1/.Android1" from adb to run the app.
I would therefore like to modify the scripts kicking off the app execution in Visual Studio 2015 to use "am" instead of "run-as", but despite browsing through settings, makefiles, and scripts containing references to "run-as" I could not find where it's done. Is it possible to do it, and how? Or is there an alternative solution that does not require rooting the device?
Related
Due to some circumstances, I needed to uninstall and install my computer's java. But after reinstalling and restarting my machine, I now get this problem.
I am using Visual Studio 2019 to create an android application using Xamarin. However I cant find my android devices to run my apps.
If I click the 'Android Emulator', It opens the Android Device Manager and asks me to create a default android device every time (Even if I created one, it keeps asking).
How am I gonna show my android devices so I could run my app?
Thank you in advance :)
Please Install Google - api supported emulators
I have been using Visual Studio 2015 / 2017 for Android application development for few years. I can deploy and debug my android apps on an Android 7.0 device without any problem. However, right after I upgraded my phone to Android 8.0, the deploy / debug operation failed with the following error message:
Could not install application 'com.omnigsoft.gameenginedemo' (my apk file path ...) on the device 'CJL5T16107010699'. Installation succeeded but the applications was not found on the device.
My android app is actually installed on the device successfully (I can start it on device manually) but it seems like that Visual Studio can not list and find the installed app (by ADB shell / pm list command), as the result, I'm unable to start debugger to debug my app on Android 8.0 device.
I notice there was another developer reported the same problem but got no answer. I'm frustrated by this right now, many thanks for any suggestions!
I finally solved the problem.
It turns out that this is an obvious bug in VS 2015 and VS 2017 (version 15.5).
Luckly, VS team has fixed this bug in the latest version so the simple solution is update VS with the latest version 15.7 update 2 (aka 15.7.2) from the official site:
https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Professional&rel=15#
Interestingly, here is what I found the bug is, in VS 2017 earlier versions, create a simply Android app named "Android1", when build and deploy to an Android 7 device, the app package is installed as:
package:/data/app/com.Android1-1/base.apk=com.Android1
When deploy to an Android 8 device, the package is istalled as:
package:/data/app/com.Android1-GLGROUzYL85gF8mDWG9J6A==/base.apk=com.HelloAndroid1
Oviously the strange surffix "GLGROUzYL85gF8mDWG9J6A==" appended after the installed folder make VS unable to detect the installed app package, then it reports deployment failure.
I use ADB command "adb shell pm list packages -f -3" to list installed apps on device, I guess VS does the same thing.
Anyway, it is fixed in VS 15.7.2. Cheers!
Update:
The app package installation path still contains sort of encrypted string on Android 8 deivce, buy VS now can detect the app package anyway.
I am new to Xamarin. I used Xamarin. Forms template to create a sample mobile solution in Visual Studio 2017. The process created four projects Xamarin PCL, Xamarin Android, Xamarin.iOS and Xamarin.UWP. Without making any modification to the generated solution, I am trying to run it.
The first issue is, when I set the UWP as the starting project, the Windows emulator shows up and runs the app perfectly. But when I try to do the same with Android, I get different errors at different times based on the environment changes I make. Finally, using the visual studio android emulator, the Phone UI shows up but not my app. In the background, I can see that Visual Studio completed the build process successfully without any errors but the deploy process simply hangs. I left the deploy running overnight but still running in the morning. Here is my environment.
Intel Core i7 processor
Virtualization enabled in BIOS
Windows 10 Education
32GB RAM
Hyper-V disabled in Windows
Executed bcdedit /set hypervisorlaunchtype off in the command window and rebooted.
I tried setting the above environment in different combinations but none of them seem to make the app work. When I use an android emulator from android SDK, the build process throws errors. The only emulator that even builds is the visual studio emulator. But the deploy hangs.
A second issue I have is, I have installed android SDK for version 24 and 25. But in the emulator dropdown, I can only see the emulators for 23. I checked the installation path both in visual studio and android SDK manager and they both point to the same installation folder. What do I need to make the emulators for version 24 and 25 usable?
I repeat, I did not make any change to the generated solution in visual studio before running it. I have been at it for the past three days and couldn't make it work. Please help.
I just installed Visual Studio 2017 (on Win10 15063.138) and found, like you, Xamarin projects won't deploy to Android. Here's how I got running:
Updated everything in the Android SDK Manager.
Installed the new, improved Android Emulator from MS:
https://www.visualstudio.com/vs/msft-android-emulator/
Used that to download/install an API level 23 (6.0 Marshmallow)
emulator
Started that emulator using the same tool (you'll see it running in Hyper-V Manager)
Selected same emulator in VS for deploy/debug (the emulators that ship with VS are painfully slow)
In VS, selected Android project for start-up and verified build and deploy to Android in build config mgr.
Note: MS doesn't appear to have any emulators above API level 23, so Compilation and Target settings for your Android project can be the latest, but the minimum target will have to be 6.0 (API 23).
After pulling my hair for the past few days, I finally got my Xamarin.Forms Android App to show my page on the emulator. Thanks to all the members for their suggestions. Ryan's suggestion helped a lot ( I +1ed him, thanks Ryan) but did not solve my problem. I googled further and found a suggestion that asked to change the following setting which did it for me finally. So, if anyone else get stuck like I did, please do the following (in addition to cleaning up and updating all packages):
Open up the setting for your Hyper-V vm for your emulator (while the VM is off).
Expand the Processor node on the left and click on "Compatibility".
Now put a check mark on "Migrate to a physical computer with a different processor version" on the right.
Start your emulator in the Visual Studio Emulator tool.
Now, start debug your android project in VS using the same emulator that is already running.
After a delay (there is always a delay), your app will show up on the emulator. Yey!!
Android Studio (Windows 7) is giving me the "Unable to create debug bridge" error, as this person describes:
Unable to create Debug Bridge: Unable to start adb server: Unable to obtain result of 'adb version'
I have tried pretty much every solution I've found and then realized that I just recently installed Xamarin for Visual Studio 2015 as well, and I'm thinking that has screwed up Android Studio. adb works fine from the command line. A Google search didn't turn up any relevant results for this issue but I'm hoping someone can at least confirm that these IDEs don't play nicely together, and ideally even present a solution. I can do my installation from the command line but of course that's a pain compared to just clicking a button in the IDE, not to mention the inconvenience of using the command line to view logcat.
When you installed Xamarin, did you see if another SDK was installed in a different location in your computer? Because this happened to me. I had Android Studio installed then I installed VS 2015 with Xamarin but I didn't realize that the option to install android SDK (with adb and etc) was enabled. After realizing that, I changed Xamarin configs to point to my older SDK folder (the one used by Android Studio as well), then everything worked.
I've just started a blank Cordova project on Visual Studio 2015, the intention being to use it to develop mobile apps in the future. I've been able to get it to run in the emulator on Android and even onto an iOS device (through a Mac), but I haven't been able to figure out how to run straight onto a WP8.1/Android device, or on a WP8 emulator. When I try, I get this message:
Error running one or more of the platforms: Error: cmd: Command failed with exit code 2
You may not have the required environment or OS to run this project
The Android device also says, above that:
ERROR: Failed to deploy to device, no devices found.
There's very little documentation online, and because it's all so new, Google hasn't been particularly enlightening. It's possible that I'm missing some software, but I don't know what.
For the devices, it could be that I'm supposed to select the device from a list somewhere, but I can't see anywhere that could be. For the emulator, I'm assuming I'm missing software, or a setting is wrong on my PC, but have no idea what it could be.
To fix the issue with WP8:
I had been playing around with different versions of VS... un-installing and re-installing 2013 and 2015 and eventually hit the same issue as you.
The solution here worked for me:
No Emulator lists to deploy windows phone app
I do not have an android phone to test with t the moment, so I have not seen the android device issue.