java 如何创建在 Android Studio 模拟器中使用的 SD 卡?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46272053/
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 to create SD card to use in Android Studio's emulator?
提问by joaolell
I need to download mp3 files to an sd card in Android Studio and then read them, firstly, how can i create an SD card for my emulator? Secondly, how can I add files to it? I'm a beginner so a step by step explanation would be welcome.
我需要在 Android Studio 中将 mp3 文件下载到 SD 卡,然后读取它们,首先,如何为我的模拟器创建 SD 卡?其次,如何向其中添加文件?我是初学者,因此欢迎逐步解释。
回答by lifavor
Android Studio 3.1.1
安卓工作室 3.1.1
1.Create a emulator : Tools > AVD Manager, And run it
1.创建一个模拟器:Tools > AVD Manager,然后运行它
2.Open file system explorer :View > Tool Windows > Device File Explorer
2.打开文件系统资源管理器:查看>工具窗口>设备文件资源管理器
3.In Device File Explorer: Click right button , u will see Uploadand Save as
3.在设备文件资源管理器中:单击右键,您将看到上传和另存为
Step1:
步骤1:
Step2:
第2步:
回答by chandrakant sharma
Use the mksdcard tool to create a FAT32 disk image that you can load into emulators running different Android Virtual Devices (AVDs) to simulate the presence of the same SD card in multiple devices. If you do not need a disk image that can be shared among multiple virtual devices, you do not need to use the mksdcard command. By default the emulator uses the default image that is generated by and stored with the active AVD instead.
使用 mksdcard 工具创建一个 FAT32 磁盘映像,您可以将其加载到运行不同 Android 虚拟设备 (AVD) 的模拟器中,以模拟同一 SD 卡在多个设备中的存在。如果不需要可以在多个虚拟设备之间共享的磁盘映像,则不需要使用 mksdcard 命令。默认情况下,模拟器使用由活动 AVD 生成并存储的默认图像。
Example
Create the mySdCardFile.img
disk image:
示例 创建mySdCardFile.img
磁盘映像:
mksdcard -l mySdCard 1024M mySdCardFile.img
Start two emulators with different AVDs.
Use the -sdcard
flag to specify the name and path of the disk image you created.
启动两个具有不同 AVD 的模拟器。使用该-sdcard
标志指定您创建的磁盘映像的名称和路径。
emulator -avd Pixel_API_25 -sdcard mySdCardFile.img
emulator -avd NEXUS_6_API_25 -sdcard mySdCardFile.img
Reference :
参考 :
https://developer.android.com/studio/command-line/mksdcard.html
https://developer.android.com/studio/command-line/mksdcard.html
回答by Pranav Ashok
first take your Android "Virtual Device Manager"(AVD Manager on the top with a phone icon) and click on the "pencil icon"(edit) for editing your emulator then click "Show Advanced Settings option" there you can see a radio button for SD Card select " External file" insted of Studio-managed and provide your path and click on finish.
首先使用您的 Android“虚拟设备管理器”(顶部带有电话图标的 AVD 管理器)并单击“铅笔图标”(编辑)以编辑您的模拟器,然后单击“显示高级设置选项”,您可以在那里看到一个单选按钮对于 SD 卡,选择 Studio 管理的“外部文件”并提供您的路径并单击完成。
(AVD Manager>edit(pencil icon)>Show Advanced Settings option>External file)
(AVD 管理器>编辑(铅笔图标)>显示高级设置选项>外部文件)
回答by D1 and 1ly
I did the following steps to create an external sdcard Image
我做了以下步骤来创建一个外部 sdcard 图像
Step 1: Navigate to your android sdk directory and to the following directory inside it.
第 1 步:导航到您的 android sdk 目录和其中的以下目录。
/{your_androidSdk_location}/Android/sdk/emulator
/{your_androidSdk_location}/Android/sdk/emulator
Step 2: Ensure that there is a executable file named mksdcard.
步骤 2:确保有一个名为mksdcard的可执行文件。
Step 3: Create another directory to store the image file(.img file) that is going to be created in the next step. Lets call this directory as image_dir
第三步:创建另一个目录来存放下一步要创建的镜像文件(.img文件)。让我们将此目录称为image_dir
Step4: Execute the following command
Step4:执行以下命令
./mksdcard -l mylabel 1024M image_dir/sdcard.img
Now the .img file would have been created.
现在 .img 文件就已经创建好了。
Step 5: Now edit your emulator in the AVD manager and select Advanced Settings, under the Memory and Storagesection select external file radio button for Sd Cardand choose the .img file that was created in step 4.
第 5 步:现在在 AVD 管理器中编辑您的模拟器并选择Advanced Settings,在Memory and Storage部分下为Sd Card选择外部文件单选按钮,然后选择在第 4 步中创建的 .img 文件。
Happy emulated Storage
快乐模拟存储
回答by Radost
I had the same problem. I needed a lot of space for saving images in the emulator. My solution was creating an image sdcard and attach it to emulator. I followed these steps:
我有同样的问题。我需要大量空间来在模拟器中保存图像。我的解决方案是创建一个图像 SD 卡并将其附加到模拟器。我按照以下步骤操作:
1 ) Create an image of external sdcard:
1 ) 创建外部 sdcard 的图像:
~/Library/Android/sdk/tools/mksdcard -l mySdCard 20G path/mySdCard.img
2 ) Create an emulator with the external sdcard:
2 ) 使用外部 sdcard 创建一个模拟器:
~/Libarary/Android/sdk/tools/bin/advmanager create avd -n EMULATOR_NAME -k “system-images;android-24;default;x86” -f -c path/mySdCard.img
3 ) I searched for the external storage path with adb shell because the path to push the files is not very intuitive.
3)我用adb shell搜索了外部存储路径,因为推送文件的路径不是很直观。
My sdcard path is in storage/15F5-0C07/
4 ) Push the files into external storage path
4) 将文件推入外部存储路径
~/Library/Android/sdk/platform-tools/adb push localPath /storage/15F5-0C07
I wrote all of the steps because I searched a lot for pushing the files into external storage and not into internal storage
我写了所有步骤,因为我搜索了很多将文件推送到外部存储而不是内部存储
回答by Chetan Joshi
I suggest you use Genymotion for this its working awesome.
我建议你使用 Genymotion,因为它的工作很棒。
Here is the brief:
Go to your VirtualBox VM setting / Shared folder tab.
Add a shared folder with the folder you want to share, and check the "auto mount" option.
Start your VM as usual from the Genymotion software.
Your shared folder is available in the /mnt/shared directory (multiple shared folders are supported)
这是简短的:
转到您的 VirtualBox VM 设置/共享文件夹选项卡。
添加一个共享文件夹与您要共享的文件夹,并选中“自动挂载”选项。
像往常一样从 Genymotion 软件启动您的 VM。
你的共享文件夹在/mnt/shared目录下(支持多个共享文件夹)