Tuesday 5 March 2013

Mobile Development with C#

Mobile Development using C#
Building mobile applications can be as easy as opening up your IDE, throwing something together, doing bit of testing, etc. Many people think that the indigenous languages Objectiv-C, Java, respectively, are the only choice.
However, number of platforms for building mobile apps has emerged. e.g.: PhoneGap, Appcelerator, Xamarin, etc.

Xamarin is the one that I have experienced in one of my experiment.If you are famliar with C#, then this is the right tool for you. Basically, it allowed you to build with single language - C#, class libary and runtime that work across all 3 mobiel platforms (iOS, Android and Windows). Besides, you can either develop your application via Monodev IDE or Visual Studio. So flexible.

Debugging
My experience with Xamarin is only limited to Android platform only (this is the only one can be excuted in windows, unless you have Mac).
It was fine and easy to do a debugging in the given emulator. But, I am sure you will come to a stage where you would prefer to debug it or test your application in a real device.
In Xamarin, debugging can be done over USB Connection. But, this can be achieved on paid/licensed version only. So, please do not waste your time to figure out how to do it with a trail version.

I have a HTC wildfire mobile with Android. I tried the debugging process mentioned in Xamarin website. In order to debug in real device, you need to connect your mobile with the given USB cable to your PC. And, of course you will be asked to provide a proper usb driver installed in your computer before anything.

There are number of drivers available from google, named as google usb driver, but it is only available for certain devices. Not HTC wildfire :(
http://developer.android.com/sdk/win-usb.html#WinUsbDriver

According to the developer guide for android (the above link), you may seek for the right driver via the OEM USB drivers. However, if you are using HTC mobile for development. Please finger cross. Because I personally found HTC didn't provide this kind of USB driver at all.

So, how to proceed?
Cheat sheet of installing HTC Wildfire Android SDK Drivers

In order to debug on your HTC smartphone on windows 7, you need to install USB drivers.
1. First, get Android SDK and install the Android SDK.
2. Next, need to hack or modify the driver (file) to add support for your HTC mobile. Look for "android_winusb.inf" in your machine.

Please see the settings below. Warning! it may or may not work for you. Please backup your orignal driver / file before any modification.
Again, it works for me. But, I will not responsible to any changes you have made.

Good luck. And have fun!

JL

----------------------------------------------------------------------------------------------------------------
File name:  android_winusb.inf

;
; Android WinUsb driver installation.
;
[Version]
Signature           = "$Windows NT$"
Class               = AndroidUsbDeviceClass
ClassGuid           = {3F966BD9-FA04-4ec5-991C-D326973B5128}
Provider            = %ProviderName%
DriverVer           = 08/27/2012,7.0.0000.00001
CatalogFile.NTx86   = androidwinusb86.cat
CatalogFile.NTamd64 = androidwinusba64.cat

[ClassInstall32]
Addreg = AndroidWinUsbClassReg

[AndroidWinUsbClassReg]
HKR,,,0,%ClassName%
HKR,,Icon,,-1


[Manufacturer]
%ProviderName% = Google, NTx86, NTamd64


[Google.NTx86]

;Google Nexus One
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_0D02
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_0D02&MI_01
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E11
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E12&MI_01

;Google Nexus S
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E21
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E22&MI_01
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E23
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E24&MI_01

;Google Nexus 7
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4E40
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E41
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E42
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E42&MI_01
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E44&MI_01

;Google Nexus Q
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_2C10
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_2C11

;Google Nexus (generic)
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4EE0
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE1
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE2
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE2&MI_01
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE3
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE4&MI_01
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE5
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE6&MI_01

;HTC Incredible
%SingleAdbInterface%        = USB_Install, USB\VID_0BB4&PID_0C9E
%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C9E&MI_01

; HTC Wildfire
%SingleAdbInterface%        = USB_Install, USB\VID_0BB4&PID_0C8B
%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C8B&MI_01

;T-Mobile G2
%SingleAdbInterface%        = USB_Install, USB\VID_0BB4&PID_0C91
%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C91&MI_01


[Google.NTamd64]

;Google Nexus One
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_0D02
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_0D02&MI_01
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E11
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E12&MI_01

;Google Nexus S
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E21
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E22&MI_01
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E23
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E24&MI_01

;Google Nexus 7
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4E40
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4E41
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E42
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E42&MI_01
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4E44&MI_01

;Google Nexus Q
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_2C10
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_2C11

;Google Nexus (generic)
%SingleBootLoaderInterface% = USB_Install, USB\VID_18D1&PID_4EE0
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE1
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE2
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE2&MI_01
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE3
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE4&MI_01
%SingleAdbInterface%        = USB_Install, USB\VID_18D1&PID_4EE5
%CompositeAdbInterface%     = USB_Install, USB\VID_18D1&PID_4EE6&MI_01

;HTC Incredible
%SingleAdbInterface%        = USB_Install, USB\VID_0BB4&PID_0C9E
%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C9E&MI_01

;HTC Wildfire
%SingleAdbInterface%        = USB_Install, USB\VID_0BB4&PID_0C8B
%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C8B&MI_01

;T-Mobile G2
%SingleAdbInterface%        = USB_Install, USB\VID_0BB4&PID_0C91
%CompositeAdbInterface%     = USB_Install, USB\VID_0BB4&PID_0C91&MI_01

[USB_Install]
Include = winusb.inf
Needs   = WINUSB.NT

[USB_Install.Services]
Include     = winusb.inf
AddService  = WinUSB,0x00000002,WinUSB_ServiceInstall

[WinUSB_ServiceInstall]
DisplayName     = %WinUSB_SvcDesc%
ServiceType     = 1
StartType       = 3
ErrorControl    = 1
ServiceBinary   = %12%\WinUSB.sys

[USB_Install.Wdf]
KmdfService = WINUSB, WinUSB_Install

[WinUSB_Install]
KmdfLibraryVersion  = 1.9

[USB_Install.HW]
AddReg  = Dev_AddReg

[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{F72FE0D4-CBCB-407d-8814-9ED673D0DD6B}"

[USB_Install.CoInstallers]
AddReg    = CoInstallers_AddReg
CopyFiles = CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WdfCoInstaller01009.dll,WdfCoInstaller","WinUSBCoInstaller2.dll"

[CoInstallers_CopyFiles]
WinUSBCoInstaller2.dll
WdfCoInstaller01009.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

[SourceDisksNames]
1 = %DISK_NAME%,,,\i386
2 = %DISK_NAME%,,,\amd64

[SourceDisksFiles.x86]
WinUSBCoInstaller2.dll  = 1
WdfCoInstaller01009.dll = 1

[SourceDisksFiles.amd64]
WinUSBCoInstaller2.dll  = 2
WdfCoInstaller01009.dll = 2

[Strings]
ProviderName                = "Google, Inc."
SingleAdbInterface          = "Android ADB Interface"
CompositeAdbInterface       = "Android Composite ADB Interface"
SingleBootLoaderInterface   = "Android Bootloader Interface"
WinUSB_SvcDesc              = "Android USB Driver"
DISK_NAME                   = "Android WinUsb installation disk"
ClassName                   = "Android Device"



No comments:

Post a Comment

How to run unit test for your Xamarin Application in AppCenter?

How to run unit test for your Xamarin application in AppCenter?  When we talk about Building and Distributing your Xamarin app, you m...