How do I launch the Android emulator from the command line?
I assume that you have built your project and just need to launch it, but you don't have any AVDs created and have to use command line for all the actions. You have to do the following.
- Create a new virtual device (AVD) for the platform you need. If you have to use command line for creating your AVD, you can call
android create avd -n <name> -t <targetID>
where targetID is the API level you need. If you can use GUI, just type inandroid avd
and it will launch the manager, where you can do the same. You can read more about AVD management through GUI and through command line. - Run the AVD either by using command
emulator -avd <name>
or through previously launched GUI. Wait until the emulator fully loads, it takes some time. You can read about additional options here. - Now you have to install the application to your AVD. Usually during development you just use the same Ant script you used to build the project, just select
install
target. However, you can install the application manually using commandadb install <path-to-your-APK>
. - Now switch to emulator and launch your application like on any normal device, through the launcher. Or, as an alternative, you can use the following command:
adb shell am start -a android.intent.action.MAIN -n <package>/<activity class>
. For example:adb shell am start -a android.intent.action.MAIN -n org.sample.helloworld/org.sample.helloworld.HelloWorld
. As a commenter suggested, you can also replaceorg.sample.helloworld.HelloWorld
in the line above with just.HelloWorld
, and it will work too.
Android: How to launch emulator from command line?
Open command prompt anywhere and use the following command
To get the list of available emulator
emulator -list-avds
To open a emulator
emulator -avd Nexus_5X_API_23
Mac Terminal - How to start Android Virtual Device Manager on CLI?
Use the Android SDK Tools:
avdmanager
Or you can also start it by using the command below but it's deprecated though on newer version. Before executing it, make sure to export your Android SDK's tools directory in your ~/.bash_profile
(i.e. export PATH="/Users/user/Software/android-sdk-macosx/tools:$PATH"
)
android avd
Old answer:
In order to open the avd manager on terminal, execute the following:
/usr/bin/java -Xmx256M -XstartOnFirstThread \
-Dcom.android.sdkmanager.toolsdir=/path/of/android-sdk-macosx/tools \
-classpath /path/of/android-sdk-macosx/tools/lib/sdkmanager.jar:/path/of/android-sdk-macosx/tools/lib/swtmenubar.jar:/path/of/android-sdk-macosx/tools/lib/x86_64/swt.jar \
com.android.sdkmanager.Main avd
How to create Android Virtual Device with command line and avdmanager?
If you don't care about it being a Nexus 6P, you can run
echo no | Android/Sdk/tools/bin/avdmanager create avd --force --name testAVD --abi google_apis/x86_64 --package 'system-images;android-23;google_apis;x86_64'
Why AVD Manager options are not showing in Android Studio
I had installed Android studio and was not able to access the AVD Manager directly. I had to follow the steps as mentioned below:
- Created a blank project using Android Studio
- Once the Project is ready to use I tried open action using the shortcut ctrl+shift+a option and searched for AVD Manager
AVD Manager - On double clicking the AVD Manager I got a few errors in console about the missing libararies along with the link to install the neccessary dependencies. On clicking the links which was displayed with the error message few packages which were needed were installed. Once all the required packages were installed the AVD Manager icon becomes active.
Related Topics
Should The Call to The Superclass Method Be The First Statement
Convert Image to PDF in Android
Add Viewpagerindicator to Android Studio
Hide Tablayout on Scroll of Content Instead of Toolbar
How to Change Color of Vector Drawable Path on Button Click
Not Seeing Nexus7 in Eclipse's Android Devices
Music Player Control in Notification
List View Item Swipe Left and Swipe Right
Using Audiotrack in Android to Play a Wav File
Change The Background Color of Cardview Programmatically
Firebase Console: How to Specify Click_Action for Notifications
Converting from Glsurfaceview to Textureview (Via Gltextureview)
Uninstall App Silently with System Privileges
Getting The Current Position of a Viewpager
Recyclerview Smoothscroll to Position in The Center. Android
Isvalidfragment Android API 19
Inform Activity from a Broadcastreceiver Only If It Is in The Foreground