How to make friends Android, Visual Studio and Parallels Desktop

Introduction


A few months ago, having read articles on Habré about cross-platform development using Mono and Xamarin, I was inspired to write my own applications on the Android, iOS and Windows Phone platforms. After some time, finding a job in a company that is just developing applications using Xamarin, I became the proud owner of iMac and realized that it would be nice to have a device with Android on board (yes, I get along well with Apple and Google products, although I give preference first) to have an Android emulator on the iMac (since it is not possible to keep the entire zoo of devices for your projects).

Problems


Honestly, writing code in Xamarin is a pain, especially when Visual Studio and ReSharper exist. This was one of the reasons for installing on iMac Parallels Desktop with Windows 8.1 on board (the first was the ability to develop for Windows Phone). This solved the problem with the development environment, but left the problem with the Android emulator. A search on the Internet gave knowledge of such a cool thing as Genimotion. There was only one snag - Parallels Desktop didn’t get along very well with it. Having already thought that it would still be necessary to slowly acquire the entire Android zoo, I noticed that Parallels Desktop could install Android using their tools on a virtual machine that worked perfectly together with Windows again on a virtual machine. It only remained to find a way to connect one with the other. I’ll tell you about the searches and applications of what I’ve found.

Decision


So, for success we need:
  • Mac device
  • Parallels Desktop with Android and Windows Installed
  • Visual studio
  • Xamarin (on Windows)

Android Installation Instructions on Parallels Desktop
How to install android on Parallels Desktop?

As I already mentioned, this can be done using standard tools, but if for some reason the standard Parallels Android does not suit you (for example, I didn’t find a way to rotate the screen, but on an android installed independently, this is easy) the ability to install any image you like. I tried several sources, but from here the installation was successful in 100% of cases.

So, download any image to your liking, I have android-x86-4.4-RC1.iso, open Parallels Desktop. If this is the first start, then select “Install Windows or another OS from a DVD or image” immediately, if not, then click on “+” -> Create, and then select the installation from the image and click “Continue”. In the window that opens, select the image and drag it inward.



Parallels Desktop immediately informs us that determining the OS on this image is an impossible task for him, however, do not worry about this, feel free to click "Continue". In the drop-down menu, select Other versions of Linux -> Another version of Linux, click OK.



Then you can enter the name and location of the virtual machine. StronglyI recommend that you select "Configure settings before installation." My settings are as follows:









After the settings, click "Continue", the installation of our Android starts. Next, follow the steps: Installation - Install Android-x86 to harddisk -> Create / Modify partitions -> New -> Primary -> Bootable -> Write -> yes -> Quit -> sda1 Linux -> ext3 -> Yes -> Yes -> Yes -> Reboot.
That's it, you have Android on Parallels Desktop!


First of all, we launch Parallels Desktop.

image

A list of available virtual machines opens. We leave it open for now. Now go to Parallels Desktop -> Settings



And open the Advanced tab, and on it the Network: Change settings.



Here we will need to add the IP of our Android'a to which we will deploy the project with Visual Studio.

We return to the list of virtual machines, right-click on Android and go to the settings of this virtual machine:



Here we will be interested in the "Equipment" tab, the "Network" item. In the connection type, you need to select the one to which the Mac itself is connected in the list of bridge networks:



We close the settings of the virtual machine with Android and start it. Now go to the settings of Android itself -> About the tablet -> General information and scroll through the list until we find the IP of our Andorid'a:



Go back to the Parallels Desktop settings (Settings -> Advanced -> Network: Change settings), click to "+" under the list of port forwarding rules, where we enter the information as follows (of course, changing the IP address to the address of your Android'a)



Click OK and see our IP in the list:



Android'a setup is now complete, now you need to prepare Windows, namely adb server. Therefore, we launch the virtual machine with WIndows on board.

Instructions for preparing Windows and Xamarin with installing a USB driver from Samsung
In order for everything to work correctly, first of all, you need to update and install all Extra and Tools in the Android SDK Manager, as well as download and install the API for that version of the android (and for others, if necessary), which is on your device (yes, in the end anyway, at first you need a device on an android, however, it’s good that anyone will do). After this is done, you should download the Samsung USB driver from the official site (it didn’t work for me) or from here , or try with one of these. If the choice fell on the driver from the Samsung, then after installing it, you must definitely restart the computer, connect your device to the android, then open the device manager, find your device in the list and select the driver update. Next, select the search for drivers on the computer, then click on the driver selection from the list. Select from the list of ADB Interface and finally SAMSUNG Android ADB Interface. After that, everything is ready!


Once Windows is running, go to C: \ Users \ * username * \ AppData \ Local \ Android \ android-sdk \ platform-tools and launch the console from this folder (just in case for those who don’t know - right-click - > open command window here)

We write in the console:

add kill-server
adb connect * IP address of your Android'a * It should look like

this:



Now run Visual Studio, in which we create a new Android Application project: The



list of devices should look like this (can do not load immediately):



Select the first one in the list and start the project. The result itself:



Now you can write code in Visual Studio paired with ReSharper and enjoy the process.

Conclusion


Although everything worked out, this approach has its pros and cons. From the minuses and start:
  • Every time you start Windows, you have to write adb commands to the server;
  • So far, I have managed to install only Android tablet versions on the virtual machine without the ability to change the screen size and change the orientation of the virtual machine (the screen orientation is changed by the combination of Ctrl + F9 / F10 / F11 / F12 though in Android installed with www.android-x86. org / download ).


Pros:
  • Really fast work of Android'a (even faster than on my device);
  • The ability to compare the application on three platforms at the same time, without the need to restart Windows to connect / disconnect Hyper-V;
  • Using Visual Studio as a development environment.


That’s all, I hope this guide comes in handy. Thanks for reading!

Also popular now: