简体   繁体   English

如何增加 Android 模拟器的存储空间? (INSTALL_FAILED_INSUFFICIENT_STORAGE)

[英]How to increase storage for Android Emulator? (INSTALL_FAILED_INSUFFICIENT_STORAGE)

I get this sometimes(not often) for one of my projects, couple of classes only我有时(不经常)在我的一个项目中得到这个,只有几节课
Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE

How do I increase emulator's storage?如何增加模拟器的存储空间?

On Android Studio在 Android Studio 上

Open the AVD Manager.打开 AVD 管理器。

在此处输入图像描述

Click Edit Icon to edit the AVD.单击编辑图标以编辑 AVD。

在此处输入图像描述

Click Show Advanced settings.单击显示高级设置。

在此处输入图像描述

Change the Internal Storage, Ram, SD Card size as necessary.根据需要更改内部存储、内存、SD 卡大小。 Click Finish.单击完成。

在此处输入图像描述

Confirm the popup by clicking yes.单击是确认弹出窗口。

在此处输入图像描述

Wipe Data on the AVD and confirm the popup by clicking yes.擦除 AVD 上的数据并单击是确认弹出窗口。

在此处输入图像描述

Important: After increasing the size, if it doesn't automatically ask you to wipe data, you have to do it manually by opening the AVD's pull-down menu and choosing Wipe Data.重要提示:增加大小后,如果它没有自动要求您擦除数据,您必须通过打开 AVD 的下拉菜单并选择擦除数据来手动进行。

在此处输入图像描述

Now start and use your Emulator with increased storage.现在启动并使用您的模拟器,增加存储空间。

Update更新

This answer is, as I write this, nearly eight years old, and about five years stale.在我写这篇文章的时候,这个答案已经有将近八年的历史了,而且已经过时了大约五年。 But it's still (as I write this) the "accepted" answer, because it answered the question when it was asked.但它仍然是(在我写这篇文章时)“接受”的答案,因为它在被问到时回答了这个问题。

The newer answer, that applies to the newer Android Studio tools, can be found here: https://stackoverflow.com/a/35828035/62 -- it's a great answer with screen shots.可以在此处找到适用于较新 Android Studio 工具的较新答案: https ://stackoverflow.com/a/35828035/62 - 这是一个很好的屏幕截图答案。 If you're using Android Studio, ignore the Eclipse answer below.如果您使用的是 Android Studio,请忽略下面的 Eclipse 答案。

Original Eclipse-based Answer基于 Eclipse 的原始答案

I was searching for the answer to this question, and was unsatisfied with the above answers.我正在寻找这个问题的答案,对上述答案不满意。 But then I found the answer , so here it is for future reference:但后来我找到了答案,所以在这里供将来参考:

To summarize (and clarify), in Eclipse, go to "Debug Configurations".总结(和澄清),在 Eclipse 中,转到“调试配置”。 You can find that in the drop-down under the "debug" icon.您可以在“调试”图标下的下拉菜单中找到它。 Select "target", and select a preferred emulator target to launch.选择“目标”,然后选择要启动的首选模拟器目标。 Then under "additional emulator command line options," add this:然后在“其他模拟器命令行选项”下添加:

-partition-size 1024 -分区大小 1024

Then CLOSE the emulator (and remove any devices), and click the debug icon, which will launch the preferred emulator you selected.然后关闭模拟器(并删除所有设备),并单击调试图标,这将启动您选择的首选模拟器。 This is important: Eclipse needs to launch the debugger, not AVD.这很重要:Eclipse 需要启动调试器,而不是 AVD。

That fixed the problem for me.这解决了我的问题。

Add the following to the avd config.ini将以下内容添加到 avd config.ini

disk.dataPartition.size=1024MB

Let me know if this works for you also.让我知道这是否也适合您。

I added in the line我在行中添加添加数据分区大小配​​置
增加 AVD 存储空间的屏幕截图

Run AVD Manager运行 AVD 管理器

Select your AVD and click "Details..." button.选择您的 AVD 并单击“详细信息...”按钮。

In my case AVD Manager sets disk size as在我的情况下,AVD Manager 将磁盘大小设置为

disk.dataPartition.size=4000M

This invalid value , disk is approx 500MB despite numbers specified.尽管指定了数字,但此无效值,磁盘大约为 500MB。

Go to AVR's folder by path in "AVD details".通过“AVD 详细信息”中的路径转到 AVR 的文件夹。

Edit it in config.ini to在 config.ini 中将其编辑为

disk.dataPartition.size=4000MB

and remove all .img files.并删除所有 .img 文件。

I was doing an install of an apk:我正在安装一个apk:

adb install /home/me/jones_android-arm.apk

And I was getting an error message telling me that我收到一条错误消息告诉我

/data/local/tmp/jones_android-arm.apk

was too big.太大了。 Using the sdk tools from r15, and ADT 15 I was able to use the AVD manager to manipulate some of my existing emulator's settings:使用来自 r15 和 ADT 15 的 sdk 工具,我能够使用 AVD 管理器来操作我现有的模拟器的一些设置:

Window-> AVD Manager -> (select you virtual machine) -> Edit

then going to the Hardware properties window just below "Skin:" I was able to select with the Hardware: New button 'Ideal size of partition'.然后转到“皮肤:”下方的硬件属性窗口,我可以使用硬件进行选择:新建按钮“分区的理想大小”。 I was not, however, able to set the value other than to '0'.但是,我无法将值设置为“0”以外的值。 Undaunted, I went to my ${HOME}/.android/avd directory There was a 'MyVm.avd' directory.毫不畏惧,我去了我的 ${HOME}/.android/avd 目录有一个“MyVm.avd”目录。 Going into that directory I found a 'config.ini' file.进入那个目录,我发现了一个“config.ini”文件。 There was the entry :有条目:

disk.dataPartition.size=0

I set this to:我将其设置为:

disk.dataPartition.size=1024

.. then went back to the AVD Manager, selected MyVm, selected 'Start', opted to wipe user data win the dialog following, and was able to run and install. .. 然后回到 AVD 管理器,选择 MyVm,选择“开始”,选择擦除用户数据以赢得下面的对话框,并且能够运行和安装。

只需通过命令行启动模拟器,如下所示:

emulator -avd <your avd name> -partition-size 1024 -wipe-data

avd manager has an option "ideal size of system partition", try setting that to 1024MB, or use the commandline launch option that does the same. avd 管理器有一个选项“系统分区的理想大小”,尝试将其设置为 1024MB,或使用执行相同操作的命令行启动选项。

fyi, I only encountered this problem with the 4.0 emulator image.仅供参考,我只遇到了 4.0 模拟器图像的这个问题。

you need to increase virtual memory of emulator你需要增加模拟器的虚拟内存

How to increase virtual memory of emulator如何增加模拟器的虚拟内存

emulator -avd "Emulator Name" -partition-size 2024模拟器 -avd "模拟器名称" -partition-size 2024

after then try to install your apk然后尝试安装你的apk

这个问题来自 android 1.5 .. 尝试 2.0 或 2.1 或 2.2

To resize the storage of the Android emulator in Linux:要在 Linux 中调整 Android 模拟器的存储大小:

1) install qemu 1)安装qemu

2) Locate the directory containing the img files of the virtual machine. 2)找到包含虚拟机的img文件的目录。 Something like ~/.android/avd/.avd and cd to it.像 ~/.android/avd/.avd 和 cd 之类的东西。

3) Resize the ext4 images: ie for growing from 500Mb to 4Gb execute 3) 调整 ext4 图像的大小:即从 500Mb 增长到 4Gb 执行

qemu-img resize userdata.img +3.5GB
qemu-img resize userdata-qemu.img +3.5GB

4) grow the filesystem: 4)增长文件系统:

e2fsck -f userdata.img
resize2fs userdata.img
e2fsck -f userdata-qemu.img
resize2fs userdata-qemu.img

5) For the sd card image, optional: rescue the data: 5) 对于 sd 卡镜像,可选:救援数据:

mkdir 1
mount -o loop sdcard.img 1
cp -a 1 2
umount 1

6) resize the image from 100Mb to Gb: 6) 将图像大小从 100Mb 调整为 Gb:

qemu-img resize sdcard.img +3.9GB

7) re-generate the filesystem: 7)重新生成文件系统:

mkfs.vfat sdcard.img

8) optional: restore the old data: 8) 可选:恢复旧数据:

mount -o loop sdcard.img 1
cp -a 2/* 1
mount -o loop sdcard.img 1 

If you have the M1 Mac and the preview version of Android Emulator, then you'll need to go to /Applications/Android Emulator.app/Contents/MacOS/api30-gphone-arm64-v8a/config.ini (as an example) and change the disk.dataPartition.size property to your desired size.如果你有 M1 Mac 和 Android Emulator 的预览版,那么你需要去/Applications/Android Emulator.app/Contents/MacOS/api30-gphone-arm64-v8a/config.ini (例如)并将disk.dataPartition.size属性更改为您想要的大小。

something like this:像这样的东西: 在此处输入图像描述

The reference is in the GitHub repo .参考在GitHub repo中。

Best regards.此致。

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.android.junkfoodian"
android:installLocation="preferExternal"   // this line can work for  Installation error:            //                                             // INSTALL_FAILED_INSUFFICIENT_STORAGE

I'm a beginner, but I had that problem while playing around with the "Hello Grid View".我是初学者,但在玩“Hello Grid View”时遇到了这个问题。 I was trying to use my own photos, which were all very large in file size.我试图使用我自己的照片,这些照片的文件大小都非常大。

The quick fix was to reduce the number of photos, thus reducing the size of the APK file.快速解决方法是减少照片数量,从而减小 APK 文件的大小。

But, I guess my follow up question for anybody else who hits this thread is this: How do I attach large files like JPGs and MP3s to an app and make sure they save on the SD Card so the APK remains small?但是,我想我对其他点击此线程的其他人的后续问题是:如何将 JPG 和 MP3 等大文件附加到应用程序并确保它们保存在 SD 卡上以使 APK 保持较小?

Update your settings in AVD Manager and start the device by enabling 'Wipe user data'.更新您在 AVD Manager 中的设置并通过启用“擦除用户数据”启动设备。 This worked for me.这对我有用。

我想您应该使用“emulator -wipe-data -avd YourAvdName”重新启动模拟器,或者如果您使用的是 Eclipse,请在运行配置中检查“Wipe User Data”。

The only time I've seen this happen it was when the host filesystem was basically out of space.我唯一一次看到这种情况发生是在主机文件系统基本上空间不足的时候。 Do you have much free space on the filesystem where the VM's filesystem is stored?存储 VM 文件系统的文件系统上是否有很多可用空间?

It is defenetly not a appropriate answer, but it is a small hint.这显然不是一个合适的答案,但它是一个小提示。

If you want to make use of static files in your App.如果您想在您的应用程序中使用静态文件。 You should put them as resources or as assets.您应该将它们作为资源或资产。 But, if U have memory concerns like to keep your APK small, then you need to change your App design in such a way that,但是,如果你有内存问题,比如保持你的 APK 很小,那么你需要改变你的应用程序设计,这样,

instead of putting them as resources, while running your App(after installation) you can take the files(defenately different files as user may not keep files what you need) from SD Card.而不是将它们作为资源,在运行您的应用程序(安装后)时,您可以从 SD 卡中获取文件(当然是不同的文件,因为用户可能不会保留您需要的文件)。 For this U can use ContentResolver to take audio, Image files on user selection.对于这个 U 可以使用 ContentResolver 来获取用户选择的音频、图像文件。

With this you can give the user another feature like he can load audio/image files to the app on his own choice.有了这个,您可以为用户提供另一个功能,例如他可以根据自己的选择将音频/图像文件加载到应用程序中。

您可以在eclipse平台的AVD管理器对话框中从左侧树“虚拟设备”中选择一项时启动一项,启动UI有“擦除用户数据”选项

The following approach worked for me以下方法对我有用

  1. Navigate to your android SDK/tools folder in the terminal window (in case you didn't added the path for it)在终端窗口中导航到您的 android SDK/tools 文件夹(如果您没有为其添加路径)

  2. Make sure the virtual device you're planning to clean is powered off.确保您计划清理的虚拟设备已关闭。

  3. Run the command "./emulator -wipe-data -avd YourAvdName" where YourAvdName is the name of your virtual android device运行命令“./emulator -wipe-data -avd YourAvdName”,其中 YourAvdName 是您的虚拟 android 设备的名称

I am using VSCode and my AVD setup is from an older Android Studio setup that I had not used for a while.我正在使用 VSCode,而我的 AVD 设置来自我有一段时间没有使用过的较旧的 Android Studio 设置。

I was able to fix this issue by finding the location where the AVD Images are located and then searching for files that had the text我可以通过找到 AVD 图像所在的位置然后搜索包含文本的文件来解决此问题

disk.dataPartition.size

Run a find . -name "avd*"运行find . -name "avd*" find . -name "avd*" and a grep "disk" * once you find the directory for the AVD. find . -name "avd*"grep "disk" *一旦你找到 AVD 的目录。

Modifying the disk.dataPartition.size value in the hardware-qemu.ini file worked for me.修改hardware-qemu.ini文件中的disk.dataPartition.size值对我有用。

The problem can be solved by changing your partition size of emulator.该问题可以通过更改模拟器的分区大小来解决。

Go to the your \Android\Sdk\emulator path and type the following command.转到您的 \Android\Sdk\emulator 路径并键入以下命令。

emulator -avd android_emulator_name -partition-size 1500 -wipe-data

Now it will work , you have increased the size of your partition size.现在它可以工作了,你已经增加了你的分区大小。 You can observe the change in size by using the following command before and after running the above command.您可以在运行上述命令之前和之后使用以下命令来观察大小的变化。

adb shell df

Delete this application on emulator.在模拟器上删除此应用程序。 Run again.再次运行。

Try choosing project -> clean.尝试选择项目-> 清洁。 A simple clean may fix it up.一个简单的清洁可以解决它。

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

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