Master LLMs with our FREE course in collaboration with Activeloop & Intel Disruptor Initiative. Join now!


How to Run an Android Application from the Command Line!
Latest   Machine Learning

How to Run an Android Application from the Command Line!

Last Updated on July 20, 2023 by Editorial Team

Author(s): Garima Nishad

Originally published on Towards AI.

Android, Programming

Image Courtesy: Google

Have you ever got tired of having low RAM on your PC while using IDE?

Have you ever wanted to run a single script and run all of your applications in a go?

If the answer is “Yes” to any of those questions then you’re in the right place! You won’t need any IDE to run your android application anymore! No more hanging up!

Isn’t that amazing? Let’s get into it then!

This article outlines the usage of popular tools used for Android development on the command line, in particular, Android, Android Debug Bridge (ADB) and how they can be utilized to build an Android application project and how to install and debug an Android app using the command line.


  1. Install the latest Java Development Kit (JDK) from Oracle.
  2. Install the latest Android SDK. If you have not done so yet, you can download the Android SDK on Android Developers.

So let’s begin :

  • Open the terminal.
  • To start the process, first, display a list of available Android device(s) that are currently configured, copy this command:
<your android sdk directory>/tools/android list devices

Then you’ll see something like this :

and then you’ll have your list of devices:

Now you can monitor your “ANDROID EMULATOR”

<your android sdk directory>/tools/emulator -avd <name of avd>

If you don’t know the name of your avd yet, don’t worry! You can find it out using this command:

<your android sdk directory>/tools/android list avd

You’ll see something like:

So the “Name “ part would be used to replace <name of avd> in the command line:

<your android sdk directory>/tools/emulator -avd <name of avd>

I’m assuming here that you’ve already created your android project.

Now let’s compile the android project:

Before you compile your project, you must be connected to the internet in order for the Gradle wrapper script to download the appropriate Gradle software components. Once ready, to compile your Android project, navigate to your project directory on your command line (change directory), and do this:

For Mac or Linux-

./gradlew build ()

For Windows:

gradlew.bat build

Now upload a specified APK file from your computer to an emulator/device.

<your android sdk directory>/platform-tools/adb install -r <your APK file>

If this doesn’t work then push the APK using ADB:

adb push <your android app directory>/build/outputs/apk/debug/app-debug.apk /data/local/tmp/org.tensorflow.lite.examples.classification

Then start launcher:

adb shell am start -n “org.tensorflow.lite.examples.classification/org.tensorflow.lite.examples.classification.ClassifierActivity” -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

The logcat command of ADB is used to display system information of a running Android OS (whether device or emulator). This is remarkably helpful to find out what is happening to an application or a device.

<your android sdk directory>/platform-tools/adb logcat

And there you have it, your working android application from the command line!

Screaming with joy yet?

Join thousands of data leaders on the AI newsletter. Join over 80,000 subscribers and keep up to date with the latest developments in AI. From research to projects and ideas. If you are building an AI startup, an AI-related product, or a service, we invite you to consider becoming a sponsor.

Published via Towards AI

Feedback ↓