Android Studio编译中“png-cruncher_*”异常的解决方案

最近写的几个小demo在编译时总是出现错误,打印的log如下:
……
……
Exception in thread “png-cruncher_21” java.lang.RuntimeException: Timed out while waiting for slave aapt process, make sure the aapt execute at D:\Android-SDK\Android\android-sdk\build-tools\23.0.0\aapt.exe can run successfully (some anti-virus may block it) or try setting environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds
at com.android.builder.png.AaptProcess.waitForReady(AaptProcess.java:108)
at com.android.builder.png.QueuedCruncher 1.creation(QueuedCruncher.java:110)atcom.android.builder.tasks.WorkQueue.run(WorkQueue.java:203)atjava.lang.Thread.run(Thread.java:745)Exceptioninthreadpngcruncher40java.lang.RuntimeException:Timedoutwhilewaitingforslaveaaptprocess,makesuretheaaptexecuteatD:\AndroidSDK\Android\androidsdk\buildtools\23.0.0\aapt.execanrunsuccessfully(someantivirusmayblockit)ortrysettingenvironmentvariableSLAVEAAPTTIMEOUTtoavaluebiggerthan5secondsatcom.android.builder.png.AaptProcess.waitForReady(AaptProcess.java:108)atcom.android.builder.png.QueuedCruncher 1.creation(QueuedCruncher.java:110)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:203)
at java.lang.Thread.run(Thread.java:745)
……
……
Error:Error: Could not create the Java Virtual Machine.
Error:Error: A fatal exception has occurred. Program will exit.
Error:Error: Could not create the Java Virtual Machine.
Error:Error: A fatal exception has occurred. Program will exit.
Error:Execution failed for task ‘:app:transformClassesWithDexForDebug’.
com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘C:\Program Files\Java\jdk1.7.0_79\bin\java.exe” finished with non-zero exit value 1

从log上看,说SLAVE_AAPT_TIMEOUT 的值大于5,于是增加系统变量并设置为30,再次编译还是有如上的错误,汗-_-!
继续搜索解决方法,网上说这可能与build tools有关,需要更新一下build tools。
更新build tools 重新编译,错误没了,OK搞定。


参考链接:
http://stackoverflow.com/questions/30111443/android-studio-fails-to-build-new-project-timed-out-while-wating-for-slave-aapt

http://www.maiziedu.com/article/11351/

你可能感兴趣的:(【Android错误和异常】)