如何在 Android 模拟器中安装 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?

转载于:https://stackoverflow.com/questions/3480201/how-do-you-install-an-apk-file-in-the-android-emulator

csdnceshi77
狐狸.fox It's very simple now.....Just open your emulator....drag and drop the .apk file to your emulator...that's it..!!!
3 年多之前 回复
weixin_41568183
零零乙 In xcode, it's called a simulator, although it's still an emulator (for ios).
5 年多之前 回复
csdnceshi58
Didn"t forge 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.
5 年多之前 回复
csdnceshi71
Memor.の Simulator -> Ios
6 年多之前 回复
csdnceshi70
笑故挽风 Thanks! Back then I didn't have edit privileges.
6 年多之前 回复
weixin_41568110
七度&光 edited accordingly.
6 年多之前 回复
weixin_41568184
叼花硬汉 stackoverflow.com/questions/1584617/…
7 年多之前 回复

28个回答

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

Another options:


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

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,

  1. Now open terminal and type the following: cd Library/Android/sdk/platform-tools

  2. 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 the step 5.

  3. Run your emulator from Android Studio, once emulator active then repeat step 4, you will see the success message on your terminal.

csdnceshi61
derek5. i learnt new thing today, install app on emulator while draging apk to emulator , wow great :)
大约 2 年之前 回复
csdnceshi80
胖鸭 drag and drop the .apk file also work in Genymotion
大约 2 年之前 回复
csdnceshi56
lrony* 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)
2 年多之前 回复
csdnceshi58
Didn"t forge getting this error: Failure [INSTALL_FAILED_NO_MATCHING_ABIS]
接近 4 年之前 回复
csdnceshi62
csdnceshi62 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.
大约 4 年之前 回复
csdnceshi79
python小菜 Works only if AVD or emulator is running. Start AVD or emulator before executing ./adb install FileName.apk
4 年多之前 回复
csdnceshi78
程序go 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.
5 年多之前 回复
csdnceshi78
程序go Step to install APK in Emulator
5 年多之前 回复
weixin_41568208
北城已荒凉 this is just an example but you´re right, will be more correct specifing the path to the .apk file. thank you!
6 年多之前 回复
weixin_41568174
from.. 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".
6 年多之前 回复
csdnceshi74
7*4 The Linux link is broken.
6 年多之前 回复
csdnceshi70
笑故挽风 Wasn't that - adb kill-server then adb start-server - I had started the emulator from eclipse
6 年多之前 回复
weixin_41568208
北城已荒凉 install the drivers for your device. dominantwire.com/2012/11/…
6 年多之前 回复
csdnceshi70
笑故挽风 error:device not found\nwaiting for device
6 年多之前 回复
weixin_41568208
北城已荒凉 you are right, i have that path as an example.
接近 7 年之前 回复
csdnceshi71
Memor.の 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.
接近 7 年之前 回复
csdnceshi53
Lotus@ 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.
接近 8 年之前 回复
weixin_41568183
零零乙 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.
8 年多之前 回复
csdnceshi75
衫裤跑路 The adb has moved to 'platform-tools' in Windows too
8 年多之前 回复

Drag and drop

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

You can also run your android emulator without Android Studio.

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

csdnceshi75
衫裤跑路 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.
3 年多之前 回复
weixin_41568184
叼花硬汉 I have never used that one.
3 年多之前 回复
csdnceshi75
衫裤跑路 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.
3 年多之前 回复

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
weixin_41568196
撒拉嘿哟木头 examples are always good.
大约 5 年之前 回复

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

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

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

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)

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


    }
}
csdnceshi68
local-host The simplest way! thanks
大约 3 年之前 回复
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
weixin_41568131
10.24 there is no relevance of the tools or platform-tools directory except people are by luck getting adb in their paths.
大约 4 年之前 回复
csdnceshi65
larry*wei just thought I would share that in the latest android sdk-tools adb has moved from the tools folder to the platform-tools folder
接近 8 年之前 回复
weixin_41568110
七度&光 You need to type down your emulator name as it appears on ur eclipse. For instance ./emulator -avd youremulatorname
大约 8 年之前 回复
csdnceshi60
℡Wang Yan it says ./adb No such file or directory in Mac, how should I run that ?
大约 8 年之前 回复
共28条数据 1 3 尾页
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问