6 April 2013

HTC Desire S USB Driver on Windows 7 (64bit)

So I was probably the last one to learn that by far the best way to debug Android applications is using your Android devices (tablets and phones). Mobile device emulators are simply the slowest and most painful thing a developer can be subjected to.

Here are a few issues I had while setting up my Nexus tablet and HTC phone to enable them to successfully debug my "in-progress" development directly from Eclipse.

First of all it is worth noting that all of this magic is enabled via the Android Debug Bridge or simply ADB. This modern wizardry comes in the form of an innocent command-line utility found in the /android-sdk/platform-tools/ directory. The three most useful commands that you as an Android developer should be familiar with are:

  • adb devices  Lists all connected devices
  • adb kill-server  Terminates the ADB listening server
  • adb start-server  Starts the ADB listening server (if not already running).

More information can be found the Android developer portal (surprisingly helpful based earlier experience with Google's documentation standards).

Tip #1: Remember to enable the "Unknown Sources" (Allow installation of non-Market applications) under Settings > Applications.

Tip #2: Most issues with USB device connectivity are due to issues with your device manufacturer. 99% of them can be solved by simply downloading the most up-to-date drivers.

TL;DR: I now found someone that is more to the point that I.

Nexus Tablet

After configuring the tablet correctly and connecting it to my development machine the device simply did not want to show up in adb devices.

After looking into the Device Manager I noticed that the ADB bridge had a warning symbol that indicated a driver issue.

My device being a Google device my issue was sorted out by simply right clicking the icon in the device manager, selecting Update Driver Software, clicking "Browse my computer for driver software" and pointing the driver installation wizard to look in my C:\Program Files (x86)\Android\android-sdk\ directory (remember to tick the "Include subfolders" option)


This installed the most up-to-date drivers for the tablet and removed the warning indicator from the device entry in the Device Manager. Running adb devices now listed the tablet and life was good.

HTC Desire S

So wanting to debug on a 2.3.x version of Android I intended to use my (now rather antique looking) HTC phone. Again (after configuring all the dev settings on the handset) I had issues with the device not showing up warning free in the Device Manager when I connected it.

So after downloading the latest version of the HTC Sync software suite (which contains the necessary USB drivers along with a bunch of other crap-ware). I found to my dismay that the installation wizard could not successfully install the actual HTC Driver package onto my machine (HTCDriver_4.0.1.001) Despite it politely asking me if I would mind to continue with the installation ignoring the error (NOTE: Absolutely, do not continue if this happens to you!). Not very helpful at all.

Conveniently the InstallShield installer programs support the /debuglog commandline switch which creates a rather verbose InstallShield.log file in the working directory of the installer.

This gave me the actual error that was causing the failure:

4-6-2013[11:36:34 AM]: Creating new process for prerequisite, launching command line C:\Users\SVERRI~1\AppData\Local\Temp\{262E9EF0-C352-453F-9243-7E9FE4440C54}\{26ECEF94-14F8-461F-97D6-11DCE98CEDD4}\HTCDriver_4.0.1.001_20121107.exe [open] /s /v"/quiet /norestart"
4-6-2013[11:36:49 AM]: Prerequisite process exited with return code 1624
4-6-2013[11:36:49 AM]: PrereqEngine: Return Code from EXE: 1624

So no good. Something was going wrong with the embedded install application but I knew little more.
However while halted (the polite dialog box was still open asking me if I wanted to continue) I found out that the temp file containing the driver software was still located in the temp dir. So I simply copied it from there to another directory.

Running that install using the /debuglog switch lead me finally to the actual issue with the installer.

4-6-2013[11:40:49 AM]: Checking package platform...
4-6-2013[11:40:49 AM]: Status returned from summary info: 0
4-6-2013[11:40:49 AM]: Status returned obtaining PID_TEMPLATE property: 0
4-6-2013[11:40:49 AM]: Template summary for current package: Intel;0,1033,2052,1028,1031,1036,1040,1041,1045,1049,1034,1053,1029,1030,1032,1044,2070,1043,1046,1048,1055,1025,2057,1035,1054,1042
4-6-2013[11:40:49 AM]: Package is 32-bit
4-6-2013[11:40:49 AM]: Attempting to launch: MSIEXEC.EXE /i "C:\Users\SVERRI~1\AppData\Local\Temp\{0D78BBA2-52B2-4BE2-8C8A-A63C1568EB9F}\HTCDriver.msi" /l*v+ C:\Users\SVERRI~1\AppData\Local\Temp\_HTC_Installer.log TRANSFORMS="2057.MST" SETUPEXEDIR="D:\dev\devtools" SETUPEXENAME="HTCDriver_4.0.1.001_20121107.exe"
4-6-2013[11:44:42 AM]: Launch result 1, exit code 1624

So for some reason the packaged installer thought it was executing on a 32-bit system. This was confusing the MSI installer process causing the actual failure I was having. Going back to the HTC website they specifically mentioned this release would support 64 bit systems though. So their installer must just be messing things up. I noticed near the top of the log that the installer had extracted all the driver files to another temp directory:

InstallShield setup.exe (Unicode) started, cmdline: /debuglog
Extracting setup.ini...
Extracting 'Setup.INI' to C:\Users\SVERRI~1\AppData\Local\Temp\{0D78BBA2-52B2-4BE2-8C8A-A63C1568EB9F}\Setup.INI
Extracting '0x0401.ini' to C:\Users\SVERRI~1\AppData\Local\Temp\{0D78BBA2-52B2-4BE2-8C8A-A63C1568EB9F}\0x0401.ini
...

So at a loss for any other good ideas I decided to simply copy these temp files to a more "permanent" location and executing the installer directly from there.

What do you know, the drivers work like a charm! My HTC phone showed up error free in the Device Manager and the adb devices command listed it successfully. So basically someone at HTC screwed up while packaging the driver but the driver software is good.


And all is well again...

3 comments:

  1. Hi, Would you be able to go through the htc usb driver installation fix for someone who is less technical. Thanks

    ReplyDelete
    Replies
    1. Sure thing, this guy is more to the point than I am I guess:
      http://www.htcforums.com/htc-sync/11611-htc-sync-manager-wont-intall-win7-due-htc-driver-installer-error.html#post30588

      Excerpt:
      Install HTC Sync, but when it pops-up and says the HTC Driver Installer failed, do not press OK or Cancel, but instead use Windows Explorer to search your User directory (usually under \Users\) for "HTC". It should find a file called HTCDriverInstaller.exe. Copy this file to a new directory, then cancel out of the HTC Sync install.

      Now run HTCDriverInstaller.exe. It will fail as well but, again, do not press OK or Cancel yet. Use Windows Explorer to search your User directory again for "HTC", and this time you should find a file called HTCDriver.msi. Copy this file to a new directory, then cancel out of the HTCDriverInstaller install. You may also delete the HTCDriverInstaller.exe file at this point.

      Now run HTCDriver.msi, and it should successfully install the drivers. Save this file in case you need it again in the future.

      Restart the HTC Sync install, and it should see the drivers are already installed and so proceed directly to install the HTC Sync software.

      Delete
    2. Brilliant. Thanks so much.

      Delete