简体   繁体   English

Android:如何使用外部 SD 卡创建 AVD?

[英]Android: How to create an AVD with an external sd card?

I'd like to create an Android Virtual Device against which I can test recent issues with writing to external SD cards.我想创建一个 Android 虚拟设备,我可以针对它测试最近写入外部 SD 卡的问题。 I would expect the external sd card to be found at location like "/storage/extSdCard/DCIM/" on the AVD's file system.我希望可以在 AVD 文件系统上的“/storage/extSdCard/DCIM/”等位置找到外部 SD 卡。 Any suggestions on how I can accomplish this?关于我如何做到这一点的任何建议?

To add removable storage to your AVD use:要将可移动存储添加到您的 AVD,请使用:

 ~/Android/android-sdk/tools/mksdcard [memory size] [output file] 

to create SD card image.创建 SD 卡映像。

Then pass it in Advanced AVD Settings dialog: SD card -> External file然后在高级 AVD 设置对话框中传递它:SD 卡 -> 外部文件

DONE :)完毕 :)

You can learn more about the mksdcard tool here: https://developer.android.com/studio/command-line/mksdcard您可以在此处了解有关 mksdcard 工具的更多信息: https : //developer.android.com/studio/command-line/mksdcard

You can open Android Device Monitor which is the Android symbol next to the SDK Manager.您可以打开 Android 设备监视器,它是 SDK 管理器旁边的 Android 符号。 Once opened you can see the files using the file explorer and here you can create the required folders/path for using the external SD card.打开后,您可以使用文件资源管理器查看文件,您可以在此处创建使用外部 SD 卡所需的文件夹/路径。

There is a chance that when you try and create a folder it will say it is read only, if this happens open up command prompt and using adb shell input these commands:有可能当您尝试创建一个文件夹时,它会说它是只读的,如果发生这种情况,请打开命令提示符并使用 adb shell 输入这些命令:

mount -o rw,remount rootfs /
chmod 777 /mnt/sdcard
exit

These commands are from this link这些命令来自此链接

On macOS Mojave 1.14.3 with Android Studio 3.3.1 I found the path to be slightly different.在 macOS Mojave 1.14.3 和 Android Studio 3.3.1 上,我发现路径略有不同。

Create a 128 Gb sdcard:创建一个 128 Gb 的 SD 卡:

~/Library/Android/sdk/tools/mksdcard 128G sdcard.ini

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM