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 -
1 |
$ 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 -
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
adb [ -s <serial number> ] install <path_to_your_bin>.apk where -s <serial number> is the serial number of the emulator instance. e.g. $adb devices List of devices attached emulator-5554 device $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.