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.
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 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.
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 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.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.
List all your emulators:
emulator -list-avds
Run one of the listed emulators with -avd flag:
emulator -avd name-of-your-emulator
where the emulator executable is under:
${ANDROID_SDK}/tools/emulator
Or, for newer SDKs, try:
cd ${ANDROID_HOME}/emulator
emulator -avd name-of-your-emulator
I think the best way to reach it via terminal is :
cd ~/Library/Android/sdk/emulator
Or for Windows:
cd %userProfile%\AppData\Local\Android\sdk\emulator
To run a certain AVD directly:
./emulator -avd {AVD_NAME}
To list your AVDs use :
./emulator -list-avds
Just to add here, whenever you get "error: device offline" means that connection with emulator & adb bridge has been broken due to time taken in emulator startup.
Rather than re-starting emulator at this point try below two commands which stops & start adb bridge again.
adb kill-server
adb start-server
Here you can check the options to execute this command via command-line:
emulator -avd avd_name [-option [value]] ... [-qemu args]
For example, I use it like this below:
emulator -avd ICS_ARM -wipe-data -no-boot-anim -cpu-delay 0
open CMD
Open Command Prompt
type the path of emulator in my case
C:\adt-bundle-windows-x86_64-20140702\sdk\tools
write "emulator -avd emulatorname" in my case
emulator -avd AdilVD
If you are strictly trying to run the emulator from the command line try this in OSX.
"/Applications/Android Studio.app/sdk/tools/emulator" -avd <NAMEOFDEVICE> -netspeed full -netdelay none
You can simplify it by adding an alias to the .bash_profile, and sending it to a background job.
alias android='/Applications/Android\ Studio.app/sdk/tools/emulator <NAMEOFDEVICE> -netspeed full -netdelay none &'
Let Bash know about the changes.
source ~/.bash_profile
Instructions for Mac with zsh:
Open terminal window (CTRL+ALT+T)
Run command
nano ~/.zshrc
to edit your profile
Add following lines in the opened file:
export ANDROID_SDK_HOME="~/Library/Android/Sdk"
alias emulator="$ANDROID_SDK_HOME/emulator/emulator"
Save the file (CTRL+O, CTRL+X)
Source the profile by running command source ~/.zshrc or just log out and log back in
Test by running the command:
emulator -help or emulator -list-avds
to show your simulator in terminal
and run Android emulator with command:
emulator -avd <name>
NOTE: Should be same for bash by replacing .zshrc with .bashrc
Open command prompt and go to <android-Home>\sdk\tools>emulator -avd <AVD_NAME>
Here "emulator" is the command used to open your Android Virtual Device.
If you have Git Bash you can open your emulator with a double-click, with some initial setup (tested in Windows 10 only):
Open Git Bash.
Run cd ~/AppData/Local/Android/sdk/emulator
Run ./emulator -list-avds and keep note of the emulator's name. MY_EMULATOR for example.
Open Notepad and add these two lines (insert your emulator's name instead of MY_EMULATOR):
cd ~/AppData/Local/Android/sdk/emulator; ./emulator -avd MY_EMULATOR
Save the file somewhere convinient as myfile.sh. You can change "myfile" as suits you best, but the extension .sh is needed.
Open Git Bash at the directory where you stored myfile.sh and run chmod +x myfile.sh. Remember to put your file's name instead of myfile.
And that's it! From now on, everytime you need to start that emulator, just locate your myfile.sh and double click on it and wait for your Android emulator to launch!
To list all the devices installed: emulator -list-avds
This will list all the devices installed inside your Android Studio.
To run emulator: emulator -avd device_name
For example, if you got Pixel_3a_API_30_x86 after running the command in option 1, then your command to run emulator will be: emulator -avd Pixel_3a_API_30_x86
The android create avd command is deprecated. It's now recommended to use avdmanager instead to launch emulators from the command line.
First, create a new emulator if one doesn't already exist:
avdmanager create avd --name "MyEmulator" -k "system-images;android-
26;google_apis;x86"
This assumes that you already have an X86 system image installed that matches API 26, and has the Google APIs installed.
You can then launch the emulator with emulator #MyEmulator.
Open CMD
To get all Emulator list (C:\Users\DJango\AppData\Local\Android\sdk\emulator>emulator -list-avds)
Choose any emulator
(C:\Users\DJango\AppData\Local\Android\sdk\emulator>emulator -avd Pixel_2_API_28)
(Linux)
In you terminal Copy & Paste and changing the three fields in blue
/home/YouUser/Folder/adt-bundle-linux-x86_64-20140702/sdk/tools/emulator64-x86 -avd Android5.1.1
YouUser = user of session in linux
Folder = path of folfer
Android5.1.1 = You version of android in the emulator,for example (Android4.4.2)
you can view the emulators in you folder home
cd /home/Youuser/.android/avd/
Nowadays asuming you have Android Studio installed (2.2) in my case and just 1 emulator you might use this one liner
export ANDROID_SDK_ROOT=~/Library/Android/sdk/ && emulator '#'`emulator -list-avds`
If you do this often, make it easier:
$ echo 'export ANDROID_SDK_ROOT=~/Library/Android/sdk/' >> ~/.profile
Add an alias to ~.aliases
alias androidup="emulator '#'`emulator -list-avds`"
Recall to source ~/.profile ~/.aliases before testing it
Next time just $ androidup
Go to the directory where emulator is located
${ANDROID_SDK}/tools/emulator
Check emulator list from CLI
emulator -list-avds
Run a AVD from the list
emulator -avd {avd_name}
list of avd name available on
.android/avd
/SDK_PATH/tools/emulator -netdelay none -netspeed full -avd
"AVD_NAME"
In windows, I use this PowerShell script to start it up.
$em = $env:USERPROFILE+"\AppData\Local\Android\sdk\tools\emulator.exe";
Start-Process $em " -avd Nexus_5X_API_24" -WindowStyle Hidden;
For automation (CI) we did something like below steps:
Frist, find SDK's tools location, and store in variable for later use.
tools=$ANDROID_HOME/cmdline-tools/latest/bin
arch="x86_64"
package="system-images;android-23;google_apis;$arch"
Ensure Android-image's downloaded.
$tools/sdkmanager "$package"
Accept the licenses.
echo yes | $tools/sdkmanager --licenses
Create AVD.
echo no | $tools/avdmanager create avd --force --name MyAVD --abi google_apis/$arch --package "$package"
Says "no" to "Do you wish to create a custom hardware profile? ..."
Launch emulator parallel.
$ANDROID_HOME/emulator/emulator -netdelay none -netspeed full -no-snapshot-load -no-snapshot -avd MyAVD > /dev/null &
Build APK.
./gradlew assembleDebug
At last, Android-tests (Instrumented tests) automatically detect and run on Emulator.
./gradlew connectedAndroidTest
Note that because we launch Emulator parallel, you need to wait until Emulator is ready, and that before Step #7.
Maybe count build-time with script, and if build takes less than what Emulator-launch takes, call sleep.
I am late, here but want to share so may be it help some one and me too when ever needed later :) ,
So below is the way to open emulator from command line with one command using bash script.
I am using MX Linux but process is same on all operating systems
1- First Check the installed emulators
emulator -list-avds
it will result like below
emulator -list-avds
Nexus_4_API_28
Pixel_2_API_28
2- open any plain text or code editor and create a new file and write as below
#!/bin/sh
emulator -avd Nexus_4_API_28
Nexus_4_API_28 is the emulator that i want to open you write yours which you got from first step
save this file with .sh extension
3- Then, change the permissions on the file to make it executable:
chmod u+x emu.sh
4- Now open the emulator just executing this bash script file with following command
./emu.sh
For one-click (BATCH file) launch, this is what I've done:
got the name of AVD from Android Studio -> Tools -> AVD Manager -> Click on Arrow Down and choose View Details ( for me it's Pixel_2_API_28, so change accordingly below)
create an start.bat file and put the following inside:
c:
cd C:\Program Files (x86)\Android\android-sdk\emulator\
emulator -avd Pixel_2_API_28
Explanations:
First line: for me was necessary because I am launching it from d:
Second line: for me was not working the tools\emulator
Third line:
make sure you change the name of the AVD with yours (here
Pixel_2_API_28)
Using:
launch start.bat from command line
easily type this command in cmd.
replace after Users\ your user name \
if you don't have this file reinstall android studio.
On Mac (and Linux I think), after you have created your AVD, you can make an alias:
alias run-android='~/Library/Android/sdk/tools/emulator -avd ${YOUR_AVD_NAME} &'
Note: the execution of the alias will not lock your terminal, if you want that, just remove the last '&'.
Run emulator it self will give you an error because he expect that, in your current position, you have: /emulator/qemu/${YOUR_PATFORM}/qemu-system-x86_64' to start the emulator.
I wrote this simple shell script using Zenity that lets you pick which avd you want to run. If you don't have ANDROID_HOME defined, you can just replace that with the full path to emulator.
This would be easy to do with select instead of Zenity also, but I opted for Zenity since I'm running it from the xfce-application menu (though a .desktop-file).
#!/bin/sh
opt=$(zenity --title="Choose AVD" --text="Choose which emulator to start" --list \
--column="Devices" --separator="\n" `$ANDROID_HOME/emulator/emulator -list-avds`);
$ANDROID_HOME/emulator/emulator -avd $opt
Run the first emulator available:
~/Library/Android/sdk/tools/emulator -avd `~/Library/Android/sdk/tools/emulator -list-avds | awk '{print $1}'`
A launcher script which lists existing AVDs and lets you pick the one you want. Requires python3 (at least v3.4) and a valid environment variable ANDROID_HOME or ANDROID_SDK pointing to the Android SDK dir.
#!/usr/bin/env python3
import os
import subprocess
from pathlib import Path
android_emulator_dir: Path = Path(os.environ['ANDROID_HOME'] or os.environ['ANDROID_SDK']) / 'emulator'
if android_emulator_dir.exists():
emulator_dir = android_emulator_dir.absolute()
print(f'SDK emulator dir: {emulator_dir}', end='\n\n')
proc = subprocess.Popen(['./emulator', '-list-avds'], stdout=subprocess.PIPE, cwd=emulator_dir, text=True)
avds = {idx: avd_name.strip() for idx, avd_name in enumerate(proc.stdout, start=1)}
print('\n'.join([f'{idx}: {avd_name}' for idx, avd_name in avds.items()]))
avd_idx = input("\nType AVD index and press Enter... ")
avd_name = avds.get(int(avd_idx))
if avd_name:
subprocess.Popen(['./emulator', '-avd', avd_name, '-no-boot-anim'], cwd=emulator_dir)
else:
print('Invalid AVD index')
else:
print(f'Either $ANDROID_HOME or $ANDROID_SDK must be defined!')
AppleScript version (MacOS only)
osascript -e '
set avds to paragraphs of (do shell script "~/Library/Android/sdk/emulator/emulator -list-avds")
set avd to (choose from list avds with prompt "Please select an AVD to start" default items "None" OK button name {"Start"} cancel button name {"Cancel"})
do shell script "~/Library/Android/sdk/emulator/emulator -avd " & avd & " -no-boot-anim > /dev/null 2>&1 &"
'
The script above can also be run from the Script Editor.app or from Automator.app (the bit between the single quotes). Also you can use Script Editor to save it as a native macos app: select File on the menu, press and hold the ⌥ (Option) key, select Save As and then select File Format: Application.
windows 10 what helped me:
1 cd C:\Users\xxx\AppData\Local\Android\Sdk\emulator
2 list all the available: emulator -list-avds
3 start as NON-GUI mode: emulator -avd Pixel_3a_API_30_x86 -no-window
For Windows:
Search Environment in Windows Search Bar and choose "Edit the System Environment Variable"
In the System Properties window, click on Environment Variable and specify the value of the PATH environment variable:
C:\Users\{USER}\AppData\Local\Android\Sdk\emulator.
Now open CMD or Powershell and type:
emulator -list-avds
This will show list of all AVDs.
To run specific AVD, type in CMD/Powershell: emulator -avd {EmulatorName}
If you have added correct path of the android emulator, AVD will open.
If you already have emulator and wanted to use that using command just use this 1 line code only
cd C:\Users\yourUserName\AppData\Local\Android\Sdk\emulator | ./emulator -avd Pixel_5_API_32
Thanks me Later...
Starting emulator from command line with dns help
Emulator program location : /Users/{{UserName}}/Library/Android/sdk/tools
Check existing avd :-
emulator -list-avds
Start emulator with dns set
/Users/{{UserName}}/Library/Android/sdk/tools/emulator -avd Pixel_API_26 -dns-server 8.8.8.8
Related
I listed the emulators using:
emulator -list-avds
Attempt to launch an emulator:
emulator -avd Pixel_XL_API_25
And terminal replies:
PANIC: Unknown AVD name [Pixel_XL_API_25], use -list-avds to see valid list.
ANDROID_AVD_HOME is defined but could not find Pixel_XL_API_25.ini file in $ANDROID_AVD_HOME
(Note: avd is searched in the order of $ANDROID_AVD_HOME,$ANDROID_SDK_HOME/.android/avd and $HOME/.android/avd)
The path actually seems off:
echo $ANDROID_AVD_HOME
Produces:
/Users/alex/.android
Which should be: /Users/alex/.android/avd
Fixed that, new exception:
[140737069994944]:ERROR:./android/qt/qt_setup.cpp:28:Qt library not found at ../emulator/lib64/qt/lib
Could not launch '../emulator/qemu/darwin-x86_64/qemu-system-i386': No such file or directory
Does anyone know how to resolve this?
A solution that worked helped was to update my bash profile:
export ANDROID_HOME=${HOME}/Library/Android/sdk
export PATH=${PATH}:${ANDROID_HOME}/emulator
Could not launch emulator in Android Studio
Note:
I still can't use the GUI integrated into Android Studio. I have to run the emulator command:
sudo emulator -avd Nexus_Emulator
I am using Windows 10 (64 bit) and Android Studio 2.3.
My Android emulator is located in folder:
d:\Programs\Android\avd.android\avd\Nexus_4_4.avd\
Suppose I'm in folder D:\temp.
How from folder D:\temp I can launch my emulator (from command line of pc)?
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
I could only successfully run the command from the tools folder (Windows 10):
cd %ANDROID_HOME%/tools
To get the list of available virtual devices:
emulator -list-avds
To run it:
emulator -avd Nexus_5X_API_24
You can then put this at a .bat file:
cd %ANDROID_HOME%/tools
emulator -avd YOUR_VIRTUAL_DEVICE_ID
Step for :
Copy this cd C:\Users{User}\AppData\Local\Android\Sdk\emulator from your system
Paste this on System Variable Path Setting.
List available emulators: emulator -list-avds
Start the emulator: emulator -avd {myEmulator}
None of the above answers helped me on a windows 10 machine. This is what a window user needs to do:
Go to the emulator folder: cd C:\Users\{User}\AppData\Local\Android\Sdk\emulator
List available emulators: emulator -list-avds
Start the emulator: emulator -avd {myEmulator}
For WINDOWS only
1. first step to locate your AppData in your user folder if its hidden then in file-mangaer navigate to view-hidden items(check mark)
cd C:\Users\UserName\AppData\Local\android\sdk\emulator
2. second step is to see avd(android virtual devices) available
emulator -list-avds
3. Third steo is to launch avd
emulator -avd Pixel_2_API_29
Run the following command in cmd:
Cd C:\Users\Username\Appdata\local\Android\Sdk\Emulator
.\emulator -avd Andro (Emulator Name)
You can make a shortcut by using a bat file.
Step 1 - Save the Path C:\Users\Username\AppData\Local\Android\Sdk\emulator in Environment variable.
Step 2 - Then make a .bat file and write the command
emaulator -avd (Emaulator Name)
For Windows Users:
Open CMD Then
First Locate your emulator folder directory
cd c:\Users\<Your name>\AppData\Local\Android\Sdk\tools
emulator.exe -list-avds
emulator.exe -avd emulator-name or emulator-Id
That's It. you are done.
For Mac users, open Terminal and run below commands -
Navigate to the emulator folder directory(where SDK is installed). In my case -
$ cd /Users/username/Library/Android/sdk/emulator
Then check for available emulators -
$ ./emulator -list-avds
And finally -
$ ./emulator -avd **nameofthedevice** -netdelay none -netspeed full
Simple steps i followed :
cd ~/Library/Android/sdk/tools/
./emulator -list-avds
Pick one of your available emulator name and run ./emulator -avd Nexus_5X_API_24
Emulator can also be opened from here
Open the location C:\Users{User_Name}\AppData\Local\Android\Sdk\tools
Now, open cmd from the current location.
Type the command emulator.exe -avd {NameOfYourEmulator}
This worked for me in Windows 10.
To know the list of emulators. Use the command
emulator -list-avds
Copy emulator.exe file location and paste that in global environment variable to access globaly in your system above all may be worked before but in 2020 emulator.exe is in diffrent folder
C:\Users{username}\AppData\Local\Android\emulator
for me it was
C:\Users\sachin\AppData\Local\Android\emulator
2.simply run in terminal
emulator -list-avds
emulator -avd {emulator name}
Try this way, it's Fast and no need append to syspath:
Run "Run" Win+R and put
cmd /K "cd C:\Users\{username}\AppData\Local\Android\Sdk\emulator&&emulator #{device_name}"
change {username} to your username and {device_name} to your device name
1. first step to locate your AppData in your user folder if its hidden then in file-mangaer navigate to view-hidden items(check mark)
cd C:\Users\UserName\AppData\Local\android\sdk\emulator
2. second step is to see avd(android virtual devices) available
emulator -list-avds
3. Third steo is to launch avd
emulator -avd Pixel_2_API_29
How to open the AVD manager on Ubuntu Linux from the command line?
For thoose coming here because the android avd command has been deprecated*, here's how to do it now:
Using Android Studio
Open Android Studio with a valid studio project (if you don't have one, simply create one empty). After you've your project open, go to Tools => Android => AVD Manager. Note that this menu does not appear if you don't have a valid Android Studio project open.
Now you can safely close Android Studio if you only want the AVD Manager.
From command line
If you want to use the command line you'll first need to create the virtual device using avdmanager, located under $ANDROID_HOME/tools/bin/avdmanager like so:
$ANDROID_HOME/tools/bin/avdmanager create avd --force --name testAVD --abi google_apis/x86_64 --package 'system-images;android-23;google_apis;x86_64'
After you created the device to emulate, then you need to open it with emulator, which is located under $ANDROID_HOME/tools/emulator. The command for the previously created device should be something like:
emulator -avd testAVD
If it crashes saying something like...
[140022905190208]:ERROR:./android/qt/qt_setup.cpp:28:Qt library not found at ../emulator/lib64/qt/lib
Ensure you're running the emulator command inside the $ANDROID_HOME/tools folder, otherwise may not work.
If you already added a device VM you can list them all with
emulator -list-avds
Check out the official documentation for more details (thanks to Jeff Xiao for this—in comments).
* The depreaction note says:
The android command is no longer available.
For manual SDK and AVD management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager
Use android avd to open the AVD Manager.
For me, ./android avd worked, where android was the shell script under android-studio/sdk/tools.
Sadly commands android sdk and android avd stopped working so to run emulator we need to use different commands to download and build all devices and its dependencies:
Download sdk-tools-linux (tar.gz) from:
https://developer.android.com/studio#downloads
Unpack tools to : ...android-sdk/tools (...wherever you want)
Go to : android-sdk/tools/bin
Install needed sdk libraries:
Execute in cmd
sdkmanager --update
sdkmanager "platform-tools" "platforms;android-29"
sdkmanager "build-tools;29.0.1" "extras;android;m2repository" "tools"
sdkmanager "system-images;android-29;google_apis_playstore;x86_64"
sdkmanager "emulator"
Setup environment variables
Add env to system by editing ~/.bashrc (Linux) in Windows just setup system enviroments.
export ANDROID_HOME=../android-sdk
export ANDROID_SDK_ROOT=$ANDROID_HOME
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/bin
alias emulator="sh $ANDROID_HOME/tools/emulator"
Note: There is possible that You need JAVA_HOME too.
Restart computer or cmd to load environments
Create device:
Go to /bin
avdmanager create avd -n myDevice -k "system-images;android-29;google_apis_playstore;x86_64"
run device:
Got to dir and run
cd android-sdk/tools
emulator -avd myDevice (or sh $ANDROID_HOME/tools/emulator -avd myDevice)
Issues:
qemu emulator not found in /bin....
cd android-sdk/tools/bin
ln -s android-sdk/emulator/ emulator
./android avd is deprecated use ~/Android/Sdk/tools/bin/avdmanager --help instead!
or if it is easier for you, move to the directory and use it like in the old version:
cd ~/Android/Sdk/tools/bin/
./avdmanager
check new [options] with --help or -h before you use avdmanager
first occurence in Android Studio 2.3 !
Android studio:v3.0.1
Get name:
/home/user/Android/Sdk/tools$ android list avd
Start emulator:
/home/user/Android/Sdk/tools$ emulator -avd Nexus_6_API_23
First of all to show all devices
run the following command from the location - ~/Android/Sdk/tools
/home/user/Android/Sdk/tools> ./emulator -list-avds
then you will see the list of devices id, in my case i got following devices
Nexus_5X_API_28
Nexus_9_API_28
Now just run following command with the device id you want to run.
/home/user/Android/Sdk/tools> ./emulator -avd Nexus_9_API_28
I created shortcut with this command
/path/to/Android/emulator/emulator -avd Nexus_5X_API_26
Where "Nexus_5X_API_26" is my virtual device I created in Android Studio (2.3.3). Correct name can be checked from ~/.android/avd/ folder, where are one subfolder (with extension .avd) and one file (with extension .ini) for each. There are qcow2 files which I think could be also run directly with qemu (have not tested yet).
I used a sudo bash command and that worked for me:
sudo ./avdmanager list
Here's the command-line usage for creating an AVD:
android create avd -n -t [- ] ...
Example :
android create avd -n my_android1.5 -t 2
If the target you selected was a standard Android system image ("Type: platform"), the android tool next asks you whether you want to create a custom hardware profile.
Android 1.5 is a basic Android platform.
Do you wish to create a custom hardware profile [no]
Use the create avd command to create a new AVD, specifying the --skin option with a value that references either a default skin name (such as "WVGA800") or a custom skin resolution (such as 240x432). Here's an example:
android create avd -n -t --skin WVGA800
or you can refer from :-
http://developer.android.com/tools/devices/managing-avds-cmdline.html
I tried following these steps(from here):
go to sdk folder, then go to tools.
copy your apk file inside the tool directory
./emulator -avd myEmulator
to run the emulator on mac
./adb install myApp.apk
to install app on the emulator
But when I run "./emulator -avd phoneEmulator" (phoneEmulator is the name of my emulator)
it just displays:
My-MacBook-Pro:tools myName$ ./emulator -avd phoneEmulator
2012-07-30 22:44:33.377 emulator-arm[2859:80b] Warning once: This application, or a
library it uses, is using NSQuickDrawView, which has been deprecated.
Apps should cease use of QuickDraw and move to Quartz.
It's as if that command is never returning.
If I can't input the 2nd command ./adb install myApp.apk in that window, where do I call it?
Open Terminal
go to android-sdk-mac\platform-tools
type ./adb install myApp.apk
You can work around by:
You have a *.apk file with you if you don't have, download it.
Open Android Studio and Run the emulator.
Open the finder and go to the location which contains your *.apk file.
Drag that *.apk and drop into the emulator and it will ask for confirmation after your confirmation it will install the *.apk in the emulator.
You can find it in application menu once installation succeeds.
First of all, you SHOULD NOT copy APKs to the tools or any other SDK directory.
Do not cd to the SDK directories, just add them to the PATH environment var or use their absolute path in command lines.
Then, if you want to run the emulator and then execute command from the same terminal, send the process to background (&):
$ export PATH=$PATH:/path/to/sdk/tools:path/to/sdk/platform-tools
$ emulator -avd myEmulator &
$ adb install /path/to/my.apk
You can work around by:
Upload yourapp.apk to internet. I.e: yourhost.com/yourapp.apk
Run emulator
Open internet browser on your emulator, visit link yourhost.com/yourapp.apk
Download and install
adb can be run from a seperate terminal once this emulator boots up.
May Be, Useful to all the command in MAC OS Terminal
Am I the only one whose apps install in the emulator when I run them as Android Application from eclipse?
I mean - why go though the trouble of adb when you could just use eclipse? (unless you have something against eclipse!)
Try this app. It will install the apk by just double clicking on it after you create an association to .apk files. It's all explained in the github source.
Alternatively You can use 'adb install' command as follows. "adbinstall/filename.apk"
ex. adb install /Users/manojclinberg/Downloads/ad3e0e46-d716-4fa9-b603-b8db3accf260.apk
I finally managed to obfuscate my Android application, now I want to test it by installing the APK file and running it on the emulator.
How can I install an APK file on the Android Emulator?
You can simply drag and drop the .apk file of your application to the emulator and it will automatically start installing.
Another option:
Windows:
Execute the emulator (SDK Manager.exe->Tools->Manage AVDs...->New then Start)
Start the console (Windows XP), Run -> type cmd, and move to the platform-tools folder of SDK directory.
Paste the APK file in the 'android-sdk\tools' or 'platform-tools' folder.
Then type the following command.
adb install [.apk path]
Example:
adb install C:\Users\Name\MyProject\build\Jorgesys.apk
Linux:
Copy the apk file to platform-tools in the android-sdk linux folder.
Open Terminal and navigate to platform-tools folder in android-sdk.
Then Execute this command -
./adb install FileName.apk
If the operation is successful (the result is displayed on the screen), then you will find your file in the launcher of your emulator.
Mac:
PATH=$PATH:~/Library/Android/sdk/platform-tools
Example : PATH=$PATH:/users/jorgesys/eclipse/android-sdk-mac_64/tools
Then run adb.
Mac:
1.Run the emulator,
2.then copy your .apk file and paste into /Users/your_system_username/Library/Android/sdk/platform-tools,
if you are not able to find sdk path in your mac system, do the following steps: Open finder->select Go option on top menu -> select Go to Folder option -> it will popup a window with a textfield: /Users/your_system_username/Library/Android/sdk/ -> now open platform-tools folder and paste your copied .apk file,
Now open the terminal and type the following:
cd Library/Android/sdk/platform-tools
execute the following in your terminal: ./adb install yourapkfilename.apk if you get the following error message: error: no devices found - waiting for device, follow step 5.
Run your emulator from Android Studio, once emulator active then repeat step 4, you will see the success message on your terminal.
If you've created more than one emulators or if you have an Android device plugged in, adb will complain with
error: more than one device and emulator
adb help is not extremely clear on what to do:
-d - directs command to the only connected USB device...
-e - directs command to the only running emulator...
-s <serial number> ...
-p <product name or path> ...
The flag you decide to use has to come before the actual adb command:
adb -e install path/to/app.apk
Nowadays, you can simply drag and drop the Android apk to the emulator and it will automatically starts installing.
go to sdk folder, then go to tools.
copy your apk file inside the tool directory
./emulator -avd myEmulator
to run the emulator on mac
./adb install myApp.apk
to install app on the emulator
go to the android-sdk/tools directory in command prompt and then type
adb install fileName.apk (Windows)
./adb install fileName.apk (Linux or Mac)
Copy .apk file in your SDK's platform-tools/ directory,then install the .apk on the emulator by using cmd(on windows):
adb install <path_to_your_bin>.apk
or
./adb install <path_to_your_bin>.apk
If there is more than one emulator running,
you can find all running emulators by this command:
adb devices
or
./adb devices
then you must specify the emulator upon which to install the application, by its serial number, with the -s option. For example:
adb -s emulator-5554 install path/to/your/app.apk
or
./adb -s emulator-5554 install path/to/your/app.apk
First you need to install Android Studio on your machine. Then simply follow these steps.
Go to you navigation bar and open Android Studio.
From the toolbar open AVD Manager. (If you cannot see it create a new android project)
Create a Virtual Device.
Select a hardware device that you want to install your app.
Select an android image that you want to install on your device. (If you cannot see any images you can download the require image from Recommended, x86 Images or Other images)
Add a name to your AVD.
Now the virtual device has been created and you can simply run it by clicking the play button.
Now you have setup the virtual device and now you need to install the APK file.
Download the APK file that you want to install and Drag and Drop it to the emulator.
The APK file has been successfully installed and you can see it in your applications.
Now you can simply run the installed app.
Drag and drop
Simply drag-and-drop the apk file into your emulator.
You can also run your android emulator without Android Studio.
In Genymotion just drag and drop the *.apk file in to the emulator and it will automatically installs and runs.
http://www.genymotion.com/
Download the Apk file from net and copy it to platform-tools of your SDK folder, then in command prompt go to that directory an type:
adb install filename.apk
press enter it will install in few seconds
Download apk file from browser and then just click on it (notification area). Installation will start automatically.
Goto Shell/Terminal/, reach at android-sdk/tools directory then
adb install fileName.apk // (u can run this command on windows)
or
./adb install fileName.apk //( u can run this command on linux)
Let's suppose you have to install Facebook APK on your emulator.
You can use adb to install the APK to the running emulator in OS X like this:
./adb install ~/FBAndroid-2.1.apk
And on Windows, like this:
adb install %HOMEPATH%\FBAndroid-2.1.apk
Once complete, check the apps screen of the emulator to check that the app has been installed correctly. If you need to force the upgrade of this app from a previous version, add the -r flag, like this on OS X:
./adb install -r ~/FBAndroid-2.1.apk
keep your emulator up and running.
In the command line, go inside the platform-tools folder, in your sdk folder which come with adt bundle and execute following command :
>adb install <yourFilename.apk>
This command detect your running emulator/emulators and show you the list of devices where you can install this app(show if any physical device/devices connected to your computer.). Then you can select any one, if only one emulator is running then app will directly installed on it by default.
Note: For above command your .apk file needs to be in same directory.
for more detailed tutorial follo : This link
From Windows 7 Onwards ,
Shift + Right click in your apk file folder.
Select Open Command Window Here
Type & Hit "adb install AppName.apk"
Drag and drop ".apk" file into the emulator window.
Just drag and drop your apk to emulator
(TESTED ON MACOS)
The first step is to run the emulator
emulator -avd < avd_name>
then use adb to install the .apk
adb install < path to .apk file>
If adb throws error like APK already exists or something alike. Run the adb shell while emulator is running
adb shell
cd data/app
adb uninstall < apk file without using .apk>
If adb and emulator are commands not found do following
export PATH=$PATH://android-sdk-macosx/platform-tools://android-sdk-macosx/android-sdk-macosx/tools:
For future use put the above line at the end of .bash_profile
vi ~/.bash_profile
if use more than one emulator at firs use this command
adb devices
and then chose amulatur and install application
adb -s "EMULATOR NAME" install "FILE PATH"
adb -s emulator-5556 install C:\Users\criss\youwave\WhatsApp.apk
I might be wrong, but on Windows I simply drag and drop the .apk into Android Emulator. I mean, doing all mentioned above seems to be a lot of work.
go to ADT/Android-sdk/tools directory in command prompt
1. adb install fileName.apk (Windows)
./adb install fileName.apk (Ubuntu/Linux or Mac)
06-11-2020
Drag and Drop didn't work for me on Windows 10 Pro.
Put the APK on Google Drive
Access that Google drive using Chrome browser on the Android Emulator
Then install it from there.
Note: You need to enable unknown sources within the Emulator.
Best way is to create a app, which opens the apk file on the emulator. You have to copy the .apk file to the download folder of your emulator. Then replace yourAppName.apk with your .apk name.
here is the code
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + "yourAppName.apk")), "application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
(1) You can also use gradle commands to install your APK while choosing the product and flavor (Debug or Release).
See this Guide.
./gradlew assembleDebug (Incase you don't have the APK generated)
./gradlew installDebug
Incase you want a fresh install, you can remove any earlier installed builds on the device with below commands
./gradlew uninstallDebug
./gradlew installDebug
(2) You can also use the adb commands directly:
Setup adb for command line
export PATH=/Users/mayurik/Library/Android/sdk/platform-tools/adb:/Users/mayurik/Library/Android/sdk/tool
Command line ADB install
adb -d install pathto/sample.apk (on device)
adb -e install pathto/sample.apk (on emulator)
Also check the documentation here
$ adb devices
List of devices attached
emulator-5554 device
emulator-5555 device
$ adb -s emulator-5555 install helloWorld.apk
you write the command on terminal/cmd
adb install FileName.apk.
Now you can just drag and drop the apk in emulator and it will install!
On Linux I do this:
first see which devices I currently have: emulator -list-avds
build the release cd android && ./gradlew assembleRelease
install it at the emulated device "Nexus5" (you are inside the android directory, else use the full path to apk): adb -s '8e138a9c' install app/build/outputs/apk/app-release.apk
Thats it. You can also use ./gradlew installRelease
Follow the steps :
make sure you have allowed installation from unknown sources in
settings.
Use the Android Device Monitor to copy the APK to the sdcard.
Use the builtin browser in Android to navigate to
file:///sdcard/apk-name.apk
When the notification "Download complete" appears, click it.
1) paste the myapp.apk in platform-tools folder , in my case C:\Users\mazbizxam\AppData\Local\Android\android-sdk\platform-tools, this is the link in my case it may change to you people
2)open the directory in CMD CD C:\Users\mazbizxam\AppData\Local\Android\android-sdk\platform-tools
3)Now you are in platform-tools folder , just type adb install myapp.apk
please ensure that your emulator is turn on , if every thing is ok apk will install
Start the console (Windows XP), Run -> type cmd, and move to the
platform-tools folder of SDK directory.
In case anyone wondering how to run cmd in platform-tools folder of SDK directory, if you are running a new enough version of Windows, follow the steps:
Go to platform-tools through Windows Explorer.
While holding shift right click and you will find the option "Open Command window here".
Click on it and cmd will start in that folder.
Hope it helps