Testing your app with the emulator is a good start. But, there is no alternative to actually running it on a device. Getting the app installed on a device is easy. All you have to do is export the APK and somehow manage to get it on the phone – download from a web server, send it as an email attachment or copy it into the SD card.
If you wish the debug the application on the device or view the LogCat entries, then you will need to resort to USB debugging. Google’s official documentation on this topic is here. But, the reality can be quite different, as we will see here.
Install USB Device Drivers
First step in the process is to install the USB drivers for your phone. Normally, you can download the drivers from the vendor’s web site. For HTC Thunderbolt, this is easier said than done. I couldn’t even find Thunderbolt mentioned in HTC web site.
My first attempt was to install the HTC Sync software which supposedly installs the drivers. But, as many have learned, Sync doesn’t install very well in Windows 7. That was a dead end.
After much Google searching, I found a site where someone was kind enough to store the 64bit drivers. Download the ZIP file and extract it somewhere.
Make sure that your device is not plugged in to the PC. Enable debugging by following these steps on the device:
- Open Settings.
- Go to Applications.
- Go to Development.
- Check USB Debugging.
Now, plug in the device to a USB slot of your PC. Windows will attempt to install the device drivers, which will fail.
Next, we will fix the device driver problem. Open Windows control panel. Click Devices and Printers. You will see the Android Phone device with an icon like this:
Right click it and select Properties.
Click Hardware tab. Click Properties button.
Click Change Settings.
Click the Driver tab. Click Update Driver.
Follow the wizard and point to the folder where the driver files from the ZIP file were downloaded. This will install the drivers correctly.
Just to be safe, unplug the device and after a few minutes, plug it back in.
First, we will verify that adb can “see” the device. Open a command prompt and go to the platform-tools folder of the SDK. Then run the command:
This should show your device. If you don’t see it, something is wrong and you need to make sure that the drivers have installed correctly.
Debug from Eclipse
Now, we are ready to start debugging from Eclipse. First, make sure that no virtual emulator is running. Start Eclipse. Make the application debuggable by editing AndroidManifest.xml.
Save the XML file.
Next, run your Android project like you normally would. For example, right click the project and select Run As > Android Application. Eclipse will automatically deploy your application to the device and start it there. If your device screen is locked, just slide the slider and unlock it. You should see your application running.
You should be able to view the LogCat messages in Eclipse. The viewer in Eclipse is somewhat shaky. I find myself viewing the messages from the command line. You can do that by running this command: