如何在 Android 模拟器中安装 APK 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3480201/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:23:14  来源:igfitidea点击:

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

androidandroid-emulatorinstallapk

提问by aryaxt

I finally managed to obfuscate my Android application, now I want to test it by installing the APKfile and running it on the emulator.

我终于设法混淆了我的 Android 应用程序,现在我想通过安装APK文件并在模拟器上运行它来测试它。

How can I install an APK file on the Android Emulator?

如何在 Android 模拟器上安装 APK 文件?

回答by Jorgesys

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

您只需将应用程序的 .apk 文件拖放到模拟器中,它就会自动开始安装。

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-toolsfolder of SDKdirectory.
  3. Paste the APKfile 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

  1. 执行模拟器(SDK Manager.exe->Tools->Manage AVDs...->New 然后开始)
  2. 启动控制台(Windows XP),运行 -> 输入cmd,然后移动到SDK目录的platform-tools文件夹。
  3. APK文件粘贴到“android-sdk\tools”或“platform-tools”文件夹中。
  4. 然后键入以下命令。

    adb 安装 [.apk 路径]

    例子:

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

Linux:

Linux:

  1. Copy the apk file to platform-toolsin android-sdk linuxfolder.
  2. Open Terminaland navigate to platform-toolsfolder 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.
  1. apk文件复制到platform-toolsandroid-sdk linux文件夹中。
  2. 打开终端导航到android-sdk 中的platform-tools文件夹。
  3. 然后执行这个命令 -

    ./adb 安装文件名.apk

  4. 如果操作成功(结果显示在屏幕上),那么您将在模拟器的启动器中找到您的文件。

Mac:

苹果电脑:

PATH=$PATH:~/Library/Android/sdk/platform-tools

Example : PATH=$PATH:/users/jorgesys/eclipse/android-sdk-mac_64/tools

示例:PATH=$PATH:/users/jorgesys/eclipse/android-sdk-mac_64/tools

Then run adb.

然后运行adb。

Mac:

苹果电脑:

1.Run the emulator,

1.运行模拟器,

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->selectGo 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,

2.然后复制您的.apk文件并粘贴到/Users/your_system_username/Library/Android/sdk/platform-tools
如果您在mac系统中找不到sdk路径,请执行以下步骤:打开finder->select顶部菜单上的Go选项->选择Go to Folder选项->它会弹出一个带有文本字段的窗口: /Users/your_system_username/Library/Android/sdk/-> 现在打开平台工具文件夹并粘贴您复制的 .apk 文件,

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

  2. execute the following in your terminal: ./adb install yourapkfilename.apkif 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.

  1. 现在打开终端并输入以下内容: cd Library/Android/sdk/platform-tools

  2. 在您的终端中执行以下操作:./adb install yourapkfilename.apk如果您收到以下错误消息:error: no devices found - waiting for device,请按照第 5 步操作。

  3. 从 Android Studio 运行您的模拟器,一旦模拟器处于活动状态,然后重复第 4 步,您将在终端上看到成功消息。

回答by webmat

If you've created more than one emulators or if you have an Android device plugged in, adb will complain with

如果您创建了多个模拟器或插入了 Android 设备,adb 会抱怨

error: more than one device and emulator

adb helpis not extremely clear on what to do:

adb help不是很清楚要做什么:

-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 beforethe actual adb command:

您决定使用的标志必须出现实际的 adb 命令之前

adb -e install path/to/app.apk

回答by Amt87

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

现在,您只需Android apk拖放到模拟器中,它就会自动开始安装。

回答by 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

回答by Akshat

go to the android-sdk/tools directory in command prompt and then type

在命令提示符中转到 android-sdk/tools 目录,然后键入

 adb install fileName.apk (Windows)

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

回答by Hamed Ghadirian

Copy .apk file in your SDK's platform-tools/ directory,then install the .apk on the emulator by using cmd(on windows):

将 .apk 文件复制到您的 SDK 的 platform-tools/ 目录中,然后使用 cmd(在 Windows 上)将 .apk 安装到模拟器上:

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:

然后您必须使用 -s 选项通过其序列号指定要安装应用程序的模拟器。例如:

adb -s emulator-5554 install path/to/your/app.apk

or

或者

./adb -s emulator-5554 install path/to/your/app.apk

回答by zeeawan

Drag and drop

拖放

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

只需将 apk 文件拖放到模拟器中即可。

You can also run your android emulator without Android Studio.

您也可以在没有 Android Studio 的情况下运行您的 android 模拟器

回答by Skitty

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

首先你需要在你的机器上安装 Android Studio。然后只需按照以下步骤操作即可。

  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
  1. 转到导航栏并打开 Android Studio。 在此处输入图片说明
  2. 从工具栏中打开 AVD 管理器。(如果你看不到它创建一个新的android项目) 在此处输入图片说明
  3. 创建虚拟设备。 在此处输入图片说明
  4. 选择要安装应用的硬件设备。 在此处输入图片说明
  5. 选择要安装在设备上的 android 映像。(如果您看不到任何图像,您可以从推荐、x86 图像或其他图像下载所需图像) 在此处输入图片说明
  6. 为您的 AVD 添加一个名称。 在此处输入图片说明
  7. 现在虚拟设备已创建,您只需单击播放按钮即可运行它。 在此处输入图片说明
  8. 现在您已经设置了虚拟设备,现在您需要安装 APK 文件。 在此处输入图片说明
  9. 下载您要安装的 APK 文件并将其拖放到模拟器中。 在此处输入图片说明
  10. APK 文件已成功安装,您可以在您的应用程序中看到它。 在此处输入图片说明
  11. 现在您可以简单地运行已安装的应用程序。 在此处输入图片说明

回答by Sagar

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

从浏览器下载 apk 文件,然后点击它(通知区域)。安装将自动开始。

回答by Salman Lashkarara

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

在 Genymotion 中,只需将 *.apk 文件拖放到模拟器中,它就会自动安装并运行。

http://www.genymotion.com/

http://www.genymotion.com/