How to run multiple android emulators? - android

I just started learning the Android SDK and I'm trying to run another emulator via command line. When I run the command:
android emulator -avd sender
from C:\Program Files\Android\android-sdk\tools, I get the following error.
Error: Expected verb after global parameters but found 'emulator' instead.
I actually got it to work once. I have already created an AVD called sender via AVD manager..
Am I missing something?

Try
emulator.exe -avd sender
from command line in C:\Program Files\Android\android-sdk\tools.
This will tell the emulator.exe to open android virtual device "sender", assuming that you already created one virtual device called sender.

Related

Launch my virtual Android device via command line

I have Android Studio and I have created virtual device that I want to launch via Android Studio.
In my avd folder I have this Pixel_XL_API_27.adv file that created.
Now I want to launch my virtual Android device via command line. First I wrote emulator -list-avds and received Pixel_XL_API_27.
But when I type emulator Pixel_XL_API_27 and the result that I received is this message:
No AVD specified. use #foo or -avd foo to lunch a virtual device named foo
Update
Run this:
emulator -avd Pixel_XL_API_27
For more information about options see https://developer.android.com/studio/run/emulator-commandline
UPDATE
Be sure to set ANDROID_HOME environment variable and type proper command in your terminal/cmd:
Window:
%ANDROID_HOME%\emulator\emulator.exe -avd Pixel_XL_API_27
Linux:
$ANDROID_HOME/emulator/emulator -avd Pixel_XL_API_27
The problem is sometimes (mostly in Windows) when you add emulator folder in PATH variable, and use emulator -avd avd_name command, current working directory in used to search for other SDK tools, instead of real ANDROID_HOME directory. So you should provide full path for emulator.exe file to start your emulator.

Error when launching .apk on android studio emulator

I am building an app with ai2 but I have spend hours trying to get their emulator to work, so I have exported myapp.apk and I am trying to launch it on android studio emulator.
I have followed several tuto included the answer proposed by Tarek on that thread But I am getting and error on cmd.
Here is what I tried:
run android studio as administrator, run the emulator via the AVD manager, waited until it's started.
move myapp.apk in the sdk/platform-tools folder
created a run.bat file in this folder and wrote CMD in it5. copy your desired apk to the same folder
double click on run.bat and wrote: adb install r- "myapp.apk"
Here I am getting an error on CMD: error device not found -waiting for device-. I don't understand because my emulator is running.
I have also tried to launch the emulator without starting android studio with this command emulator -avd <avd_name> [<options>] but I get this message "the system cannot find the file specified".
The error message appears because adb cannot connect to the device although it is running. This is not supposed to happen, but it does from time to time.
You can always check if adb can see the emulator by running adb devices, which should result in a list of devices it can see. If this list is empty, the device is not found. You can resolve this by adb kill-server, waiting a couple of seconds and then running adb start-server. Try running adb devices again, and the device should be listed, and the installation should succeed.
Starting an emulator can be done by running emulator #<device-name> [options]. The device name can be found by running android list avd. This will result in a list of devices of which the <device-name> will also be listed.

Android Studio Unknown Emulator running and can't be terminated

I have one emulator actively running at the moment but I see two emulators running when I run the app. One of them is an Unknown Emulator.
When I choose the Unknown emulator, the console shows this error:
Error: Could not access the Package Manager. Is the system running?
How do I terminate this Unknown Simulator? I think it's using my system's resources and degrading the performance.
Well, it was the BlueStacks emulator running in the background. Android Studio automatically detects it. The unknown simulator was there because BlueStacks was running in the background at the Notification Tray in my windows 8.1
When I closed BlueStacks from the Notification Tray, the Unknown emulator vanished for good.
First reason if your emulator in offline.
To resolve this you need to run command kill-server from adb.
Open Command prompt->navigate to android sdk-> go to platform-tools-> adb kill-server -> adb start-server
You need to run above command to remove unknown
Second reason if your project configuration not match with emulator configuration
Change your emulator configuration with your project requirement. May be your application version not match with emulator configuration
It was very simple to fix for my case :) Just need to type the following 2 commands using CMD:
adb kill-server
adb start-server
Make sure that the windows PATH variable contains "adb.exe" file's directory location. Normally, it should be:
YOUR_PATH_TO_SDK\platform-tools
//For example: D:\sdk\platform-tools

AVD Manager, why can't I create an AVD?

For some reason, I cannot create an AVD. I went through AVD Manager - Cannot Create Android Virtual Device and attempted the solutions, and I also fiddled with the different settings in the manager, including changing the name to Device. I made sure that the system images are installed, and I followed the instructions for using the Intel Atom. Why is the OK greyed out?
I even ran the AVD Manager from eclipse, from the exe, and from monitor.bat
For reference, I did install the Atom's image:
For some reason, running the AVD via command line worked, but I couldn't check Use Host GPU. Thanks to Rusher who got this from https://stackoverflow.com/a/22213144/1896169 . See Running Your App | Android Developers for instructions on running via command line:
From the command line, change directories to <sdk>/tools/ and execute:
android avd
In other words, typing this into command line should work:
cd whateverThePathToYourSDKIs/tools/
android avd
You can only use either Snapshot or Host GPU.
Snapshot or Host GPU they can not be used simultaneously.
now try to start avd from avd manager.

android emulator on eclipse won't open

I've gotten it to work before but now the android emulator on eclipse refuses to open. No new window, nothing. Most of the time the console says nothing when I tell it to launch, other times it says "The connection to adb is down, and a severe error has occured." but if I try again after waiting a bit it goes away then it says Launching.... and does nothing.
I try to delete the avds and it says they are currently running in emulators and cannot be deleted even though there are no windows open. I tried re-installing the (1.6) SDK and that didn't work.
Oh and I'm using Ubuntu
Edit The console is finally working, after complaining about adb, I ran it again and I got
"Launching a new emulator with Virtual Device "XXX" and then nothing
then I tried to launch a different project with the same emulator and got:
Automatic Target Mode: Preferred AVD "XXX" is not available. Launching new emulator.
Launching a new emulator with Virtual Device "XXX"
Run adb kill-server and then sudo adb start-server and then adb devices and see if you see the emulator. Sometimes the emulator is running but it hides somewhere. Also trying running the app in debug mode. Also the emulator can be just damn slow sometimes. adb is a command located in the sdk tools directory I think. Add it to your path and it will save you a lot of time. You can also do install and uninstall of your apps using command. Then tell us what you see.
I did have the same issue and I solved it by running the emulator from the command line. Go to the tools folder in the SDK package and start the emulator from there, use the name of the emulator you setup in Eclipse (in Virtual Device Manager):
./emulator -avd [the name]
The GUI should either come up (the GUI comes up fairly quick but will "idle" quite a bit) or you'll probably get an error on the command line. For me it was a missing library, namely libGL.so. Install a lib with apt-get containing libGL and retry.
sudo apt-get install libgl1-mesa-dev:i386
./emulator -avd [the name]
I did some googling and I'm not the only one, and of course those libs are missing in a 64 bit environment. Here's another one with the same problem.
Hope it helps!

Categories

Resources