ChatGPT解决这个技术问题 Extra ChatGPT

How do you install an APK file in the Android emulator?

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?

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.
In xcode, it's called a simulator, although it's still an emulator (for ios).
It's very simple now.....Just open your emulator....drag and drop the .apk file to your emulator...that's it..!!!

L
Leon

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.


The adb has moved to 'platform-tools' in Windows too
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.
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-<date>/sdk/platform-tools.
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".
getting this error: Failure [INSTALL_FAILED_NO_MATCHING_ABIS]
w
webmat

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

Good stuff. Just to be clear: it's about how many emulators are running (not created) while executing adb install. Using -s <serial number> to unequivocally target a specific emulator bypasses this issue; the serial number can be gleaned from the output of adb devices -l.
j
jeet.chanchawat

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


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.
I have never used that one.
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 Drag and drop from a lower privilege process to a higher privilege process is forbidden since Windows Vista. See docs.microsoft.com/en-us/archive/blogs/patricka/…
my emulator just hangs on installing apk; any idea why?
a
aryaxt
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

it says ./adb No such file or directory in Mac, how should I run that ?
You need to type down your emulator name as it appears on ur eclipse. For instance ./emulator -avd youremulatorname
just thought I would share that in the latest android sdk-tools adb has moved from the tools folder to the platform-tools folder
there is no relevance of the tools or platform-tools directory except people are by luck getting adb in their paths.
P
Primoz990

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)

H
Hamed Ghadirian

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

S
Skitty

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.


A
Amir Dora.

Drag and drop

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

You can also run your android emulator without Android Studio.


S
Sal-laS

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

http://www.genymotion.com/


S
Sagar

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


K
Koen.

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


d
duggu

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)

E
Erick Filho

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

A
Anonymous

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


Y
Yeahia2508

Just drag and drop your apk to emulator


D
Don Chakkappan

From Windows 7 Onwards ,

Shift + Right click in your apk file folder.

Select Open Command Window Here

Type & Hit "adb install AppName.apk"


A
Amir Dora.

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


This appears to be just a repeat of this existing answer.
N
N0mi

(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


C
Criss

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

J
Juri Noga

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.


Why post this answer if you are so unsure? Looks like you basically copied Amt87's answer.
I'm so unsure because i don't know if will work on his case. I can't see Amt87's answer.
Super easy. Way easier than other answers, and it works great on OS X.
This appears to be just a repeat of this existing answer.
v
vikseln

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

./adb install fileName.apk (Ubuntu/Linux or Mac)


S
Sampath

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.


M
Marius

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


    }
}

M
Mayuri Khinvasara

(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.


H
Hassaan Akbar

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


This appears to be just a repeat of this existing answer.
s
suther

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.


A
Amitabha Biswas

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


M
Max

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.

https://i.stack.imgur.com/TIqKC.png

Hope it helps