unity使用gradle方式打包遇到的坑(1)

在win上打包可能会遇到这样的错误

Running dex as a separate process.

To run dex in process, the Gradle daemon needs a larger heap.
It currently has 1024 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to at least 33280 MB (based on the dexOptions.javaMaxHeapSize = 32g).
To do this set org.gradle.jvmargs=-Xmx33280M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html

:org.vortexcannon.LastMan:mergeDebugJniLibFolders
:org.vortexcannon.LastMan:transformNative_libsWithMergeJniLibsForDebug
:org.vortexcannon.LastMan:processDebugJavaRes UP-TO-DATE
:org.vortexcannon.LastMan:transformResourcesWithMergeJavaResForDebug
:org.vortexcannon.LastMan:validateSigningDebug
:org.vortexcannon.LastMan:packageDebug
Expiring Daemon because JVM Tenured space is exhausted
Daemon will be stopped at the end of the build after running out of JVM memory
Exception in thread "pool-7-thread-1" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3236)
    at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
    at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
    at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:253)
    at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:211)
    at java.io.FilterOutputStream.write(FilterOutputStream.java:97)
    at com.android.builder.internal.packaging.zip.compress.DeflateExecutionCompressor.immediateCompress(DeflateExecutionCompressor.java:70)
    at com.android.builder.internal.packaging.zip.compress.ExecutorCompressor.lambda$compress$0(ExecutorCompressor.java:55)
    at com.android.builder.internal.packaging.zip.compress.ExecutorCompressor$$Lambda$225/575637572.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Exception in thread "pool-7-thread-2" java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3236)
    at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
    at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
    at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
    at java.util.zip.DeflaterOutputStream.deflate(DeflaterOutputStream.java:253)
    at java.util.zip.DeflaterOutputStream.write(DeflaterOutputStream.java:211)
    at java.io.FilterOutputStream.write(FilterOutputStream.java:97)
    at com.android.builder.internal.packaging.zip.compress.DeflateExecutionCompressor.immediateCompress(DeflateExecutionCompressor.java:70)
    at com.android.builder.internal.packaging.zip.compress.ExecutorCompressor.lambda$compress$0(ExecutorCompressor.java:55)
    at com.android.builder.internal.packaging.zip.compress.ExecutorCompressor$$Lambda$225/575637572.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:748)
Exception in thread "pool-7-thread-3" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-4" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-5" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-6" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-7" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-8" java.lang.OutOfMemoryError: Java heap space
Exception in thread "pool-7-thread-9" java.lang.OutOfMemoryError: Java heap space
Expiring Daemon because JVM Tenured space is exhausted
Exception in thread "pool-7-thread-10" java.lang.OutOfMemoryError: Java heap space
Daemon is stopping immediately JVM garbage collector thrashing and after running out of JVM memory

FAILURE: Build failed with an exception.

* What went wrong:
Gradle build daemon has been stopped: JVM garbage collector thrashing and after running out of JVM memory

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


C:\Windows\system32\cmd.exe DONE (1)
C:\Windows\system32\subst.exe /d Z:


C:\Windows\system32\subst.exe DONE (0)
System.Exception: Build Failed
   в ..(Dictionary`2 , String , String , Boolean )
   в Igor.AndroidBuilder.Package()Igor complete.
elapsed time 00:05:11.2807770s for command "C:\ProgramData/GameMakerStudio2/Cache/runtimes\runtime-2.0.6.93/bin/Igor.exe" -options="C:\Users\Vortex\AppData\Local\GameMakerStudio2\build.bff"  -- Android Package started at 05/10/2017 10:53:24
FAILED : Package Program Complete

解决方案:

在路径Copied it to C:\Users\***\.gradle下面创建一个gradle.properties文件,在其中写入

org.gradle.parallel=true
org.gradle.daemon=true
org.gradle.jvmargs=-Xmx12800M
org.gradle.configureondemand=true

 

这个错误的大致原因就是打大型apk包时会出现jvm空间不够的情况,小包情况下不会出现。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值