'How to execute android application in command line of Android Studio?
If for example I have simple android project and I want to run it from command line of Android Studio. How can I do that? I want to enter some commands into command line:
ant debug adb install bin/MyFirstApp-debug.apk
Where can I find command line in Android Studio? Thanks for any help.
Solution 1:[1]
I've tried to use the Windows terminal to do the cmd like "adb logcat", but it says "adb is not recognized." So I just found a solution provided by the following link, which works fine for me:
https://www.youtube.com/watch?v=yjutSsQn2Ic
Steps to setup adb on windows :
1) Open command promt and type adb
you will see this message :'adb' is not recognized
2) Now Download sdk(adt bundle) from http://developer.android.com/sdk/index.html
the ADT Bundle includes everything you need to begin developing apps: Eclipse + ADT plugin Android SDK Tools Android Platform tools The latest Android platform The latest Android system image for the emulator
3)Extract the zip to c drive with name "AndroidSDK" Open the platform-tools folder, you will find the adb.exe file
4)Now click on my computer and select properties
5) Click on advanced system settings
6) Choose environment variables
7) From system variables, choose path and double click on it
8)At the end of variable values put a semicolon ; and address of platform tools folder, for me it is C:\AndroidSDK\platform-tools
9)Now click OK
10)Open command prompt and type adb
11) You will see it is working
Solution 2:[2]
View -> Tool Windows -> Terminal (Alt + F12)
appears to be the menu navigation for newer versions of Android Studio (1.2.1.1, at this time)
Solution 3:[3]
To open terminal in android studio Android Studio Arctic Fox
View -> Tool Window -> Terminal (or) Alt + F12
Solution 4:[4]
You can either run your apk on an emulator or directly on a device via the adb CLI.
Devices
Find your preferred plugged in device ID:
adb devices
Install onto your device (or emulator if no device ID) with the following command:
adb -s "your-device-ID" install bin/MyFirstApp-debug.apk
You can also run with the following command:
adb shell am start -n com.app.name/com.app.name.LaunchActivity
Emulators / AVDs
List your emulators:
emulator -list-avds
Run a specific emulator:
emulator -avd device_name
eg:
emulator -avd Pixel_5_API_30
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | Al Lelopath |
| Solution 3 | Rohit S |
| Solution 4 |

