如何在 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
How do you install an APK file in the Android emulator?
提问by aryaxt
回答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:
视窗:
- 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-toolsfolder of SDKdirectory.
- Paste the APKfile 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
- 执行模拟器(SDK Manager.exe->Tools->Manage AVDs...->New 然后开始)
- 启动控制台(Windows XP),运行 -> 输入cmd,然后移动到SDK目录的platform-tools文件夹。
- 将APK文件粘贴到“android-sdk\tools”或“platform-tools”文件夹中。
然后键入以下命令。
adb 安装 [.apk 路径]
例子:
adb install C:\Users\Name\MyProject\build\Jorgesys.apk
Linux:
Linux:
- Copy the apk file to
platform-tools
inandroid-sdk linux
folder. - Open Terminaland navigate to platform-toolsfolder 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.
- apk文件复制到
platform-tools
的android-sdk linux
文件夹中。 - 打开终端并导航到android-sdk 中的platform-tools文件夹。
- 然后执行这个命令 -
./adb 安装文件名.apk
- 如果操作成功(结果显示在屏幕上),那么您将在模拟器的启动器中找到您的文件。
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->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,
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 文件,
Now open 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 the step 5.Run your emulator from Android Studio, once emulator active then repeat step 4, you will see the success message on your terminal.
现在打开终端并输入以下内容:
cd Library/Android/sdk/platform-tools
在您的终端中执行以下操作:
./adb install yourapkfilename.apk
如果您收到以下错误消息:error: no devices found - waiting for device
,请按照第 5 步操作。从 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 help
is 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.
回答by Skitty
First you need to install Android Studio on your machine. Then simply follow these steps.
首先你需要在你的机器上安装 Android Studio。然后只需按照以下步骤操作即可。
- 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.
回答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 文件拖放到模拟器中,它就会自动安装并运行。