Deploy or Install Android App
In the previous sections Build Android App and Connect Android Target, we learnt that the output of build is the .apk file and the target that we want to install the .apk file has to be connected in first place
Connect and identify target
Identify the emulators or devices that are connected to the machine
Anyones-mac-mini: pmacharl$ adb devices
List of devices attached
emulator-5554 device
emulator-5556 device
emulator-5558 device
00a219ae09d05912 device
Each line after the "List of devices attached" represents either an emulator or device. Emulator has the word "emulator-xx" prefixed and device has a serial number
Direct Commands to Target
adb can direct commands to a specific target using the below syntax
adb -s <serial_number> <command>
If there is only one device connected, use the "-d" switch. Similarly if there is only one emulator connected, use the "-e" switch.
To be on safe side, using "-s" switch will ensure there is only one matched target.
Install on emulator
Install on emulator-5554
adb -s emulator-5556 install myapp.apk
Install on real device
Install on device
adb -s 00a219ae09d05912 install myapp.apk
Output - command line Route
As you can see below are the commands. Sometimes, if there is too much delay (>5 min), then we might have to kill adb and start it over again (see below). 99% of the times, we might not have to do that, except when we might leave the device running for a week or so. That should anyways be handled as part of your mobile device lab set up, where you refresh/reset adb connections at a certain interval.
Output - Android Studio Route
If you have chosen to use Android Studio, then click the run button next to app icon and the following dialog box should appear.
Click OK. You will be able to see the exact commands in the terminal below - copying the .apk file to /data/* folder in the device and then installing the app and automatically attaching the debugger to the running process and so on. The output should look similar to the below. You have plenty of information here to munge like logcat tab, adb log files and so on
At this point, you should be able to see activity on your mobile device and the app should be launched with the home activity screen displayed.