I'm on Mac, working on Android development from the terminal. I have successfully created the HelloWorld project and now I'm trying to run it from the command line in the Android emulator. Which command runs the emulator for my HelloWorld project?
I already have the Android tools and platform-tools in my PATH.
Edit:
How do I tell the emulator to run my HelloWorld project from the command line? I've already built the project with ant.
However, you can install the application manually using command adb 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.
To start the Android Emulator and run an app in your project: In Android Studio, create an Android Virtual Device (AVD) that the emulator can use to install and run your app. In the toolbar, select the AVD that you want to run your app on from the target device drop-down menu. Click Run .
Using Android Studio After you've your project open, go to Tools => Android => AVD Manager .
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.
android create avd -n <name> -t <targetID>
where targetID is the API level you need. If you can use GUI, just type in android 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.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.install
target. However, you can install the application manually using command adb install <path-to-your-APK>
.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 replace org.sample.helloworld.HelloWorld
in the line above with just .HelloWorld
, and it will work too.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With