Installing Application to Phone using "ant installd" Command

This section provides a tutorial example on how to install the debug package of my 'HelloAndroid' application to my LG-P925g phone using the 'ant installd' command through the USB debugging interface.

I think I am ready try to install my own applications on my LG-P925g phone and debug/test them.

Let's try to install the "HelloAndroid" debug package to my phone first using the "ant installd" command. See previous tutorials on how to build the debug package.

C:\herong\HelloAndroid>\local\apache-ant-1.8.3\bin\ant installd
Buildfile: C:\herong\HelloAndroid\build.xml

-set-mode-check:

-set-debug-files:

install:
     [echo] Installing
            C:\herong\HelloAndroid\bin\HelloAndroid-debug.apk
            onto default emulator or device...
     [exec] error: more than one device and emulator

BUILD FAILED
C:\local\android-sdk-windows\tools\ant\build.xml:1194:
The following error occurred while executing this line:
C:\local\android-sdk-windows\tools\ant\build.xml:1208:
exec returned: 1

Total time: 0 seconds

Ok. We have an error here. I have both the emulator and the USB device running. The "ant" command does not know which one to use.

I don't see how to provide a command option to help the "ant" command. I am going to shut down my Android emulator to resolve the problem.

Go to the emulator Windows and close it. Then rerun the "ant installd" command:

C:\herong\HelloAndroid>\local\apache-ant-1.8.3\bin\ant installd
Buildfile: C:\herong\HelloAndroid\build.xml

-set-mode-check:

-set-debug-files:

install:
     [echo] Installing
            C:\herong\HelloAndroid\bin\HelloAndroid-debug.apk
            onto default emulator or device...
     [exec]     pkg: /data/local/tmp/HelloAndroid-debug.apk
     [exec] Success
     [exec] 228 KB/s (14980 bytes in 0.064s)

installd:

BUILD SUCCESSFUL
Total time: 2 seconds

It works this time! "ant installd" installed my debug package of "HelloAndroid" to my LG-P925g phone through the USB debugging interface.

To verify, go to the phone and tap on "Applications". You will see "HelloAndroid" listed in the "Downloads" section.

Table of Contents

 About This Book

 Installing JDK 1.8 on Windows System

 Installation of Android SDK R24 and Emulator

 Installing Apache Ant 1.9 on Windows System

 Developing First Android Application - HelloAndroid

 Android Application Package (APK) Files

 Android Debug Bridge (adb) Tool

 Android File Systems

 AboutAndroid - Application to Retrieve System Information

 android.app.Activity Class and Activity Lifecycle

 View Objects and Layout Resource Files

 Using "adb logcat" Command for Debugging

 Build Process and Package File Content

 Building Your Own Web Browser

 Android Command Line Shell

 Samsung Galaxy Tab 3 Mini Tablet

 USB Debugging Applications on Samsung Tablet

 Android Tablet - LG-V905R

 USB Debugging Applications on LG-V905R Tablet

 Android Phone - LG-P925g

USB Debugging Applications on LG-P925g Phone

 Installing LG USB Device Driver on Windows

 Viewing LG Android USB Device in Control Panel

 Turning on USB Debugging on LG-P925g

 Viewing USB Debugging Devices in Control Panel

 Running "adb" on LG-P925g USB Debugging Interface

Installing Application to Phone using "ant installd" Command

 Installing Application to Phone using "adb -d install" Command

 "adb -d install" Command Options

 Installing "AboutAndroid" to LG-P925g Phone

 Developing Applications with Android API Level 7

 Archived Tutorials

 References

 Full Version in PDF/EPUB