Xamarin: How to Set Up an Android Device for Debugging
Join the DZone community and get the full member experience.Join For Free
xamarin comes with some emulators for development of an android app. while these emulators are working and are also available in all supported screen sizes, the performance of them is really bad.
that’s why i chose debugging via device, which is a lot faster than the emulators once you have the required xamarin extensions installed.
here is how to set up an android device for debugging. first thing you need to know is which os version is running. on most android devices, you will find this information under settings/about (or info)/software information. if you don’t have the result there, you should check the manual where to find this information on your device.
activate debugging until android 3.2
- go to settings from your application menu
- choose applications
- open the development item
- you will see now the option to activate usb debugging:
activate debugging on android 4.0, 4.1
- go to the settings menu
- choose developer options and activate usb debugging:
activate debugging on android 4.2 and higher
- go to the settings menu
- select about
- tap the build number 7 times (after the 4th tap a notification will appear that counts down the required taps)
now our devices are ready to be connected to our pc, where we need to install the corresponding usb drivers. normally you just need to plug in your android device, windows will search for the right driver and install it for you. if you want to install the driver manually, here is a list of oem driver packages: http://developer.android.com/tools/extras/oem-usb.html#drivers
deploying an app for debugging
after the drivers have been installed, your device should now be recognized by windows and also by xamarin studio.
using our gettingstarted project from my first blog post, you should have now two options to deploy the application to your device:
just hit ‘debug’…
xamarin studio installs now the required packages for debugging, and after that, you will be able to debug you application.
speeding up re-deployments
xamarin will install all developing packages including your app from scratch every time you deploy the app. to speed things up, there is an option to speed things a little up.
to activate/check if this option is already activated, click on the ‘options’ button of your project and select ‘options’ in the context menu:
select ‘android build’ and activate these two options:
this way, xamarin will deploy only changes that have been made to your code, while keeping the required packages on your device. xamarin studio will detect if an update to those packages is required.
however, sometimes you will need to clean your solution and do a complete re-deploy (like you are doing with a windows phone project sometimes, too).
in very seldom cases (happened 3 times to me by now), you will need to uninstall your app and all of the xamarin packages from your device. to do so, go to settings/apps on your device. in the application list, you will find some apps that start with ‘mono’:
to uninstall them, tap the items and select ‘uninstall’ in the app info screen:
xamarin studio will now re-deploy all required packages to your device, and your app should run again for debugging.
like always, i hope this post is helpful for some of you.
Published at DZone with permission of Marco Siccardi, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.