Note: Check the parent post here.
In this stage, we shall build, test, and deploy the Hello World application on the emulator. We will use an emulator, as we do not have an actual Android device.
Step 1 – Building and Running the Application
All developed applications must be signed before they are run on an emulator or device. As we do not intend to publish our application, we will sign it in debug mode. This is done for us by the Ant build script.
To create the .apk file, navigate to the root of your project directory and issue the command -
$ ant debug
If the build is successful, then this step creates the debug .apk file inside the project bin/ directory as
Step 2 – Deploying the Application on the Emulator
To run the application on the emulator, we need to install it on the emulator. If there is more than one instance of the emulator, we can select the emulator on which we want to install our application.
To find the list of the emulator instances, execute the command adb devices
To install the application on the emulator, issue the command -
adb [ -s <serial number> ] install <path_to_your_bin>.apk
-s <serial number> is the serial number of the emulator instance.
List of devices attached
$adb -s emulator-5554 install ~/android/MyAndroidAppProject/bin/MyAndroidApp-debug.apk
This installs the .apk file on the emulator as can be seen in the illustrations below.