Debugging on a phone

The emulators, which are provided by the Android development team and integrated in Xamarin, are great pieces of technology but do have some limitations. For example, in the previous chapter, we saw that they don't support most of the hardware interactions, such as NFC, GPS, or Accelerometer. Consequently, some of your applications will have to be developed and tested on real devices.

Getting ready

To follow this recipe you will, obviously, need an Android phone and a USB cable to connect it to your PC/MAC.

How to do it...

To get started with debugging on a phone, you'll need to perform the following steps:

  1. Enable the Debugging on Device feature of your Phone. On Android 4.0 and 4.1, it's under Setting | Developer Options | USB Debugging. Starting with Android 4.2, the developer option is hidden and you have to activate it by pressing seven time on the build number by navigating to Settings | About phone.
    How to do it...
  2. On Windows, you need to install the USB Driver by executing the android.bat file located in the tools folder of your Android SDK installation.
  3. Download and install the USB driver made by your phone manufacturer as explained at: http://developer.android.com/tools/extras/oem-usb.html#Drivers.
  4. Your phone should now be recognized by Xamarin and you can run, test, and debug your application directly on it.

How it works...

The processes involved in debugging on an emulator or a physical phone are exactly the same.

Tip

If you stop Xamarin and disconnect your USB cable, the application will stay on your phone and you will be able to use it afterward.

See also

Go to http://www.learn2crack.com/2014/07/adb-android-debug-bridge-over-wifi.html to learn how to debug over Wi-Fi instead of USB.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.28.50