简体   繁体   English

android studio无法构建和运行项目文件太大

[英]android studio cannot build and run the project The file is too large

My app is for view images When user click on next button show next image or back button show the previous image, the problem started When I tried to run the project I see some error about images size 我的应用程序用于查看图像当用户单击下一个按钮显示下一个图像或后退按钮显示上一个图像时,问题开始了当我尝试运行该项目时,我看到有关图像大小的一些错误

"The file is too large; 80.83M. Showing a read-only of the first 2.56M". “文件太大; 80.83M。显示前2.56M的只读内容”。


I tried this solution the privous message is disappered but I still see some errors 我尝试了此解决方案,但私密消息已消失,但我仍然看到一些错误

Error:error: failed to read data meta data.
Error:failed parsing overlays.
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt

The first error 第一个错误

在此处输入图片说明

The second error 第二个错误

在此处输入图片说明

1) Write android:largeHeap="true" in your manifest under application. 1)在应用程序下的清单中编写android:largeHeap="true"

2) Go to File -> Invalidate caches/restart -> Just restart. 2)转到文件->使缓存无效/重新启动->仅重新启动。 This will clear all caches. 这将清除所有缓存。

3) Go to Build -> Clean project 3)转到构建->清理项目

4) Go to Build -> Rebuild project 4)转到构建->重建项目

Why do you need a PNG this big? 为什么需要这么大的PNG? A good practice is to keep your APK size as small as possible, with a reasonable size for an app like yours around 4MB. 一个好的做法是使APK的大小尽可能的小,对于像您这样的应用,合理的大小约为4MB。 Even if you crunch these PNG images they will still be way too big and result in a huge size of your APK. 即使您压缩这些PNG图像,它们也仍然太大而导致APK很大。

According to the Android Developers' guide: 根据Android开发者指南:

Users often avoid downloading apps that seem too large, particularly in emerging markets where devices connect to often-spotty 2G and 3G networks or work on pay-by-the-byte plans. 用户通常避免下载看起来太大的应用程序,特别是在新兴市场中,这些设备连接到经常出现故障的2G和3G网络或按字节付费计划工作。

More info: here 更多信息: 这里

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

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