Android Build报错:Failed to obtain compression information for entry(已解决)

1
2
3
4
5
6
7
8
9
10
11
12
FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':packageRelease'.
> Failed to obtain compression information for entry

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 12s

先说一下项目是如何报错的。如果asset目录资源很少,或者不放资源,是没有这个报错的,但是要加上资源才会这样。
再结合我们项目资源很大的原因,结合报错,我猜测应该是打包的时候申请的打包内存不足导致的。

知道了原因问题解决起来就相对容易了很多。

新建一个文件,起名为gradle.properties
文件中加入:org.gradle.jvmargs=-Xmx3072M
后面的3072就是1024的三倍,也就是3g的打包内存。
将该文件放在和build.gradle同级目录,Clear一下工程。
这样,在打包的时候,就不会再报这个错误了。这种错误也属于常见错误了。

分享就到这里如果有疑问或者有什么建议,欢迎在下面留言或者加UnityのSchool技术交流群讨论。