831

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?

Old McStopher
  • 6,295
  • 10
  • 60
  • 89
aryaxt
  • 76,198
  • 92
  • 293
  • 442
  • 6
    http://stackoverflow.com/questions/1584617/simulator-or-emulator-what-is-the-difference – slf Nov 19 '12 at 19:39
  • Step to install APK in Emulator : Step 1 -> Run the emulator step 2-> Paste the apk in SDK manager tools and platform-tools folders. Step 3->Run this command adb install AppNaem.APK .Wait for 2 min it's show Success Message. Sometimes App icon closed unfortunatl. But App will run continuous Try / click. – gnganapath Nov 12 '14 at 12:02
  • In xcode, it's called a simulator, although it's still an emulator (for ios). – JVE999 Jan 23 '15 at 20:57
  • It's very simple now.....Just open your emulator....drag and drop the .apk file to your emulator...that's it..!!! – Akhilesh Sinha Feb 24 '17 at 03:04

36 Answers36

1158

You can simply drag and drop the .apk file of your application to the emulator and it will automatically start installing.

Another option:


Windows:

  1. Execute the emulator (SDK Manager.exe → Tools → Manage AVDs... → New then Start).

  2. Start the console (Windows XP), Run → type cmd, and move to the platform-tools folder of SDK directory.

  3. Paste the APK file in the android-sdk\tools or platform-tools folder.

  4. Then type the following command.

    adb install [.apk path]
    

    Example:

    adb install C:\Users\Name\MyProject\build\Jorgesys.apk
    

Linux:

  1. Copy the apk file to platform-tools in the android-sdk linux folder.

  2. Open Terminal and navigate to platform-tools folder in android-sdk.

  3. Then execute this command:

    ./adb install FileName.apk
    
  4. 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.

double-beep
  • 5,031
  • 17
  • 33
  • 41
Jorgesys
  • 124,308
  • 23
  • 334
  • 268
  • 45
    The adb has moved to 'platform-tools' in Windows too – Dimuthu Mar 10 '12 at 15:26
  • 6
    Just wanted to add a little something that is missing from the above answer. You must put the apk file in the "android-sdk\tools" directory. With this information, the answer works perfectly. – Camille Sévigny Apr 10 '12 at 15:17
  • The answer works perfectly with @CamilleSévigny comment. You should first put the apk file in the tools directory, then set the path in cmd with the same as that of tools direcory and at last execute the apk. – Sahil Mahajan Mj Oct 08 '12 at 11:55
  • 12
    Seems that the location of the APK can be freely chosen, as long as it is referenced correctly in the `adb install` command (verified on a Mac). As for the location of `adb`: on a Mac, as of at least ADT bundle version 20130522, the platform tools can be found in `$HOME/Development/adt-bundle-mac-x86_64-/sdk/platform-tools`. – mklement0 Sep 04 '13 at 15:38
  • @Mr_and_Mrs_D, install the drivers for your device. http://www.dominantwire.com/2012/11/how-to-solve-adb-device-not-found-error.html – Jorgesys Oct 21 '13 at 15:20
  • 1
    Wasn't that - `adb kill-server` then `adb start-server` - I had started the emulator from eclipse – Mr_and_Mrs_D Oct 21 '13 at 17:40
  • The Linux link is broken. – Grzegorz Oledzki Jan 04 '14 at 13:28
  • 30
    You should not put the .apk in the platform-tools directory. Your project doesn't belong there. Use the full path on 'adb install' instead, e.g. 'adb install "C:\Users\Name\MyProject\build\myapp.apk". – Ela782 Mar 11 '14 at 19:59
  • this is just an example but you´re right, will be more correct specifing the path to the .apk file. thank you! – Jorgesys Mar 11 '14 at 21:14
  • Step to install APK in Emulator – gnganapath Nov 12 '14 at 11:57
  • Step to install APK in Emulator : Step 1 -> Run the emulator step 2-> Paste the apk in SDK manager tools and platform-tools folders. Step 3->Run this command adb install AppNaem.APK .Wait for 2 min it's show Success Message. Sometimes App icon closed unfortunatl. But App will run continuous Try / click. – gnganapath Nov 12 '14 at 12:02
  • Works only if AVD or emulator is running. Start AVD or emulator before executing `./adb install FileName.apk` – Naveen Agrawal Dec 30 '15 at 12:21
  • This needs to be corrected so people understand the irrelevance of the apk location. They are probably accidentally getting adb in the path by going to the tools or platform-tools directory. – Hal50000 May 01 '16 at 14:28
  • 13
    getting this error: Failure [INSTALL_FAILED_NO_MATCHING_ABIS] – IAmNoob Aug 25 '16 at 21:59
  • @IAmAndroid because you are using an APK file for a different architecture. Search google for more. (That was an old comment but replying because it might help others) – Manoranjan Dec 26 '17 at 08:29
  • i learnt new thing today, install app on emulator while draging apk to emulator , wow great :) – Ramkesh Yadav Jul 07 '18 at 11:57
  • I had a problem with Drag & Drop installation but I have discovered something. If I rename apk installation file to shorted form and then use Drag & Drop everything works fine. – Sobansky Jul 17 '19 at 12:31
  • On MAC OS works perfect for me: adb install theapkfilename.apk Thank you! Great Feedback! – Didierh Jul 30 '20 at 19:25
  • On Windows: Use `%USERPROFILE%\AppData\Local\Android\Sdk\platform-tools\adb install \path\to\build.apk` – xyhhx Jul 31 '20 at 05:26
  • i was testing this on huawei cloud debugging. adb install was showing no progress. Took a lot of time but finally installed for drag and drop option. – Kaveri Dec 14 '21 at 07:19
133

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
webmat
  • 58,466
  • 12
  • 54
  • 59
  • 8
    Good stuff. Just to be clear: it's about how many emulators are *running* (not created) while executing `adb install`. Using `-s ` to unequivocally target a specific emulator bypasses this issue; the serial number can be gleaned from the output of `adb devices -l`. – mklement0 Sep 04 '13 at 15:17
93

Nowadays, you can simply drag and drop the Android apk to the emulator and it will automatically starts installing.

jeet.chanchawat
  • 5,842
  • 5
  • 38
  • 59
Amt87
  • 5,493
  • 4
  • 32
  • 52
  • 6
    Is there something you need to do to enable this? Maybe it's different for the Visual Studio emulator, but drag and drop does not appear to work. – chad Feb 26 '17 at 18:48
  • I have never used that one. – Amt87 Feb 27 '17 at 07:55
  • 10
    For others: drag and drop APK installs in Visual Studio Android Emulator do not work if the emulator was launched as Administrator. Who knows why. – chad Feb 28 '17 at 21:28
  • @chad Drag and drop from a lower privilege process to a higher privilege process is forbidden since Windows Vista. See https://learn.microsoft.com/en-us/archive/blogs/patricka/q-why-doesnt-drag-and-drop-work-when-my-application-is-running-elevated-a-mandatory-integrity-control-and-uipi – Holistic Developer Apr 07 '20 at 19:21
  • my emulator just hangs on installing apk; any idea why? – evanjmg Sep 07 '20 at 13:06
31
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
aryaxt
  • 76,198
  • 92
  • 293
  • 442
  • it says ./adb No such file or directory in Mac, how should I run that ? – CanCeylan Jun 06 '12 at 19:50
  • You need to type down your emulator name as it appears on ur eclipse. For instance ./emulator -avd youremulatorname – kkocabiyik Jun 10 '12 at 20:39
  • 5
    just thought I would share that in the latest android sdk-tools adb has moved from the tools folder to the platform-tools folder – Jeff Wooden Aug 10 '12 at 18:06
  • there is no relevance of the tools or platform-tools directory except people are by luck getting adb in their paths. – Hal50000 May 01 '16 at 14:30
27

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)
Primoz990
  • 1,716
  • 2
  • 20
  • 34
Aishvarya Jaiswal
  • 1,793
  • 6
  • 34
  • 72
26

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
Hamed Ghadirian
  • 6,159
  • 7
  • 48
  • 67
  • It's also important that the `-s ` (for example, `-s emulator-5554`) comes before `install`. In other words, `./adb install -s emulator-5554` would NOT work. – Jesse Nov 17 '22 at 20:18
23

First you need to install Android Studio on your machine. Then simply follow these steps.

  1. Go to you navigation bar and open Android Studio. enter image description here
  2. From the toolbar open AVD Manager. (If you cannot see it create a new android project) enter image description here
  3. Create a Virtual Device. enter image description here
  4. Select a hardware device that you want to install your app. enter image description here
  5. 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) enter image description here
  6. Add a name to your AVD. enter image description here
  7. Now the virtual device has been created and you can simply run it by clicking the play button. enter image description here
  8. Now you have setup the virtual device and now you need to install the APK file. enter image description here
  9. Download the APK file that you want to install and Drag and Drop it to the emulator. enter image description here
  10. The APK file has been successfully installed and you can see it in your applications. enter image description here
  11. Now you can simply run the installed app. enter image description here
Skitty
  • 1,709
  • 18
  • 21
19

Drag and drop

Simply drag-and-drop the apk file into your emulator.

You can also run your android emulator without Android Studio.

Amir Dora.
  • 2,831
  • 4
  • 40
  • 61
zeeawan
  • 6,667
  • 2
  • 50
  • 56
14

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

Koen.
  • 25,449
  • 7
  • 83
  • 78
ravijena
  • 151
  • 1
  • 8
13

In Genymotion just drag and drop the *.apk file in to the emulator and it will automatically installs and runs.

http://www.genymotion.com/

Sal-laS
  • 11,016
  • 25
  • 99
  • 169
12

Download apk file from browser and then just click on it (notification area). Installation will start automatically.

Sagar
  • 430
  • 4
  • 14
11

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)
duggu
  • 37,851
  • 12
  • 116
  • 113
10

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
Erick Filho
  • 1,962
  • 3
  • 18
  • 31
Fakhar
  • 3,946
  • 39
  • 35
8

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

Anonymous
  • 1,726
  • 4
  • 22
  • 47
8

Just drag and drop your apk to emulator

Yeahia2508
  • 7,526
  • 14
  • 42
  • 71
BIS Tech
  • 17,000
  • 12
  • 99
  • 148
7

From Windows 7 Onwards ,

Shift + Right click in your apk file folder.

Select Open Command Window Here

Type & Hit "adb install AppName.apk"

Don Chakkappan
  • 7,397
  • 5
  • 44
  • 59
7

Drag and drop ".apk" file into the emulator window.

Amir Dora.
  • 2,831
  • 4
  • 40
  • 61
Dan Alboteanu
  • 9,404
  • 1
  • 52
  • 40
  • This appears to be just a repeat of [this existing answer](https://stackoverflow.com/a/37943159). – Pang Nov 13 '18 at 05:01
5

(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

N0mi
  • 714
  • 7
  • 14
5

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
Criss
  • 755
  • 7
  • 22
5

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.

Juri Noga
  • 4,363
  • 7
  • 38
  • 51
Marcelo Agimóvel
  • 1,668
  • 2
  • 20
  • 25
4

go to ADT/Android-sdk/tools directory in command prompt 1. adb install fileName.apk (Windows)

  1. ./adb install fileName.apk (Ubuntu/Linux or Mac)
vikseln
  • 458
  • 6
  • 8
4

06-11-2020

Drag and Drop didn't work for me on Windows 10 Pro.

  1. Put the APK on Google Drive

  2. Access that Google drive using Chrome browser on the Android Emulator

  3. Then install it from there.

Note: You need to enable unknown sources within the Emulator.

Sampath
  • 63,341
  • 64
  • 307
  • 441
2

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);


    }
}
Marius
  • 15,148
  • 9
  • 56
  • 76
ORY
  • 393
  • 1
  • 4
  • 11
2

(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
Mayuri Khinvasara
  • 1,437
  • 1
  • 16
  • 12
1

you write the command on terminal/cmd adb install FileName.apk.

1

Follow the steps :

  1. make sure you have allowed installation from unknown sources in settings.
  2. Use the Android Device Monitor to copy the APK to the sdcard.
  3. Use the builtin browser in Android to navigate to file:///sdcard/apk-name.apk
  4. When the notification "Download complete" appears, click it.
1

Now you can just drag and drop the apk in emulator and it will install!

Hassaan Akbar
  • 195
  • 3
  • 12
  • 1
    This appears to be just a repeat of [this existing answer](https://stackoverflow.com/a/37943159). – Pang Nov 13 '18 at 05:00
1

On Linux I do this:

  1. first see which devices I currently have: emulator -list-avds
  2. build the release cd android && ./gradlew assembleRelease
  3. 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

suther
  • 12,600
  • 4
  • 62
  • 99
0

Simple You can upload APK to file hosting or download APK and use browser to install from unknown source .

Thoman
  • 742
  • 2
  • 9
  • 20
0

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

Amitabha Biswas
  • 3,281
  • 1
  • 11
  • 23
shamnad
  • 328
  • 5
  • 21
0

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:

  1. Go to platform-tools through Windows Explorer.
  2. While holding shift right click and you will find the option "Open Command window here".
  3. Click on it and cmd will start in that folder.

enter image description here

Hope it helps

Atiq
  • 14,435
  • 6
  • 54
  • 69
0

Late, but to be completed with options here: A handy tool to install any apk via gui to a running emulator is: http://apkinstaller.com

This can directly connect to a running instance via adb and can successfully install any kind of apk packages.

Maybe this is also helpful for other people. ;)

SiL3NC3
  • 690
  • 6
  • 29
0

you can try build and run application manually

  • build View -> Tool Windows -> Build Variants
  • run Tasks -> install -> install<build_varaiant>
  • open adb shell am start -n <package_name>/.<activity_name>

[more]

yoAlex5
  • 29,217
  • 8
  • 193
  • 205
-1

In mac or windows . Just run the emulator and Drag and drop the apk on the home screen . It will install

Faheem
  • 930
  • 10
  • 7
-1

Just drag and drop apk file in the emulator and done....

-1

You can click a button in the menu of the emulator window that says "Install External APK." It will then prompt you to enter the location of the APK or choose it in a file browser. Select the file then click install and it will install it to the emulator's device.

default123
  • 151
  • 1
  • 2
  • 12