Gradle 构建错误(Android Studio 2.2.2)
Posted
技术标签:
【中文标题】Gradle 构建错误(Android Studio 2.2.2)【英文标题】:Gradle build error(Android Studio 2.2.2 ) 【发布时间】:2017-03-25 11:11:52 【问题描述】:我在 Debian Jessie 上安装了带有必要软件包的 android Studio 2.2.2 并检查更新
gradle build 开始时出现 2 个错误:
错误:java.lang.RuntimeException:Crunching Cruncher launcher.png 失败,查看日志 错误:任务 ':app:mergeDebugResources' 执行失败。
我在这个论坛上寻找答案,我试图通过编辑 /res/drawable 文件夹中的 png 文件来解决这个错误。我使用 Pinta 图像编辑器并将文件保存为 launcher.png
我还检查了 gradle.build 文件并确保那里显示的 SDK 构建工具版本持续版本 (25.0.0)
模块 gradle 文件:
apply plugin: 'com.android.application'
android
compileSdkVersion 10
buildToolsVersion "25.0.0"
defaultConfig
applicationId "com.project.project"
minSdkVersion 10
targetSdkVersion 19
buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
dependencies
compile 'com.android.support:support-v4:18.0.0'
compile files('libs/httpmime-4.0.jar')
项目级 gradle 文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript
repositories
jcenter()
dependencies
classpath 'com.android.tools.build:gradle:2.2.2'
allprojects
repositories
jcenter()
Gradle 控制台
Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:prepareDebugDependencies
:app:compileDebugAidl
:app:compileDebugRenderscript
:app:generateDebugBuildConfig
:app:generateDebugResValues
:app:generateDebugResources
:app:mergeDebugResources
AAPT err(Facade for 1101934): /root/Android/Sdk/build-tools/25.0.0/aapt: 3: /root/Android/Sdk/build-tools/25.0.0/aapt: Syntax error: Unterminated quoted string
AAPT err(Facade for 29345672): /root/Android/Sdk/build-tools/25.0.0/aapt: 3: /root/Android/Sdk/build-tools/25.0.0/aapt: Syntax error: Unterminated quoted string
Exception while processing task java.lang.RuntimeException: AAPT process not ready to receive commands
Thread(png-cruncher_5): Broken pipe
java.io.IOException: Broken pipe
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:326)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at com.android.builder.png.AaptProcess.shutdown(AaptProcess.java:143)
at com.android.builder.png.QueuedCruncher$1.destruction(QueuedCruncher.java:144)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:245)
at java.lang.Thread.run(Thread.java:745)
Exception while processing task java.lang.RuntimeException: AAPT process not ready to receive commands
Thread(png-cruncher_4): Broken pipe
java.io.IOException: Broken pipe
at java.io.FileOutputStream.writeBytes(Native Method)
at java.io.FileOutputStream.write(FileOutputStream.java:326)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at com.android.builder.png.AaptProcess.shutdown(AaptProcess.java:143)
at com.android.builder.png.QueuedCruncher$1.destruction(QueuedCruncher.java:144)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:245)
at java.lang.Thread.run(Thread.java:745)
Error: java.lang.RuntimeException: Crunching Cruncher launcher.png failed, see logs
AAPT err(Facade for 14139714): /root/Android/Sdk/build-tools/25.0.0/aapt: 3: /root/Android/Sdk/build-tools/25.0.0/aapt: Syntax error: Unterminated quoted string
Exception while processing task java.lang.RuntimeException: AAPT process not ready to receive commands
AAPT err(Facade for 3636584): /root/Android/Sdk/build-tools/25.0.0/aapt: 3: /root/Android/Sdk/build-tools/25.0.0/aapt: Syntax error: Unterminated quoted string
Exception while processing task java.lang.RuntimeException: AAPT process not ready to receive commands
Thread(png-cruncher_3): Stream closed
java.io.IOException: Stream closed
at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433)
at java.io.OutputStream.write(OutputStream.java:116)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at com.android.builder.png.AaptProcess.shutdown(AaptProcess.java:143)
at com.android.builder.png.QueuedCruncher$1.destruction(QueuedCruncher.java:144)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:245)
at java.lang.Thread.run(Thread.java:745)
Thread(png-cruncher_2): Stream closed
java.io.IOException: Stream closed
at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433)
at java.io.OutputStream.write(OutputStream.java:116)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at com.android.builder.png.AaptProcess.shutdown(AaptProcess.java:143)
at com.android.builder.png.QueuedCruncher$1.destruction(QueuedCruncher.java:144)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:245)
at java.lang.Thread.run(Thread.java:745)
:app:mergeDebugResources FAILED
AAPT err(Facade for 5293242): /root/Android/Sdk/build-tools/25.0.0/aapt: 3: /root/Android/Sdk/build-tools/25.0.0/aapt: Syntax error: Unterminated quoted string
Thread(png-cruncher_1): Stream closed
java.io.IOException: Stream closed
at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433)
at java.io.OutputStream.write(OutputStream.java:116)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at com.android.builder.png.AaptProcess.shutdown(AaptProcess.java:143)
at com.android.builder.png.QueuedCruncher$1.destruction(QueuedCruncher.java:144)
at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:245)
at java.lang.Thread.run(Thread.java:745)
Process list not empty
Thread(png-cruncher_3): queue not cleaned
while shutting downpng-cruncher_3
java.io.IOException: Stream closed
at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433)
at java.io.OutputStream.write(OutputStream.java:116)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at com.android.builder.png.AaptProcess.shutdown(AaptProcess.java:143)
at com.android.builder.png.QueuedCruncher$1.shutdown(QueuedCruncher.java:161)
at com.android.builder.tasks.WorkQueue.shutdown(WorkQueue.java:169)
at com.android.builder.png.QueuedCruncher.end(QueuedCruncher.java:309)
at com.android.builder.internal.aapt.v1.AaptV1.lambda$compile$0(AaptV1.java:430)
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:745)
Thread(png-cruncher_4): queue not cleaned
while shutting downpng-cruncher_4
java.io.IOException: Stream closed
at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433)
at java.io.OutputStream.write(OutputStream.java:116)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at com.android.builder.png.AaptProcess.shutdown(AaptProcess.java:143)
at com.android.builder.png.QueuedCruncher$1.shutdown(QueuedCruncher.java:161)
at com.android.builder.tasks.WorkQueue.shutdown(WorkQueue.java:169)
at com.android.builder.png.QueuedCruncher.end(QueuedCruncher.java:309)
at com.android.builder.internal.aapt.v1.AaptV1.lambda$compile$0(AaptV1.java:430)
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:745)
Thread(png-cruncher_1): queue not cleaned
while shutting downpng-cruncher_1
java.io.IOException: Stream closed
at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433)
at java.io.OutputStream.write(OutputStream.java:116)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at com.android.builder.png.AaptProcess.shutdown(AaptProcess.java:143)
at com.android.builder.png.QueuedCruncher$1.shutdown(QueuedCruncher.java:161)
at com.android.builder.tasks.WorkQueue.shutdown(WorkQueue.java:169)
at com.android.builder.png.QueuedCruncher.end(QueuedCruncher.java:309)
at com.android.builder.internal.aapt.v1.AaptV1.lambda$compile$0(AaptV1.java:430)
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:745)
Thread(png-cruncher_2): queue not cleaned
while shutting downpng-cruncher_2
java.io.IOException: Stream closed
at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433)
at java.io.OutputStream.write(OutputStream.java:116)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at com.android.builder.png.AaptProcess.shutdown(AaptProcess.java:143)
at com.android.builder.png.QueuedCruncher$1.shutdown(QueuedCruncher.java:161)
at com.android.builder.tasks.WorkQueue.shutdown(WorkQueue.java:169)
at com.android.builder.png.QueuedCruncher.end(QueuedCruncher.java:309)
at com.android.builder.internal.aapt.v1.AaptV1.lambda$compile$0(AaptV1.java:430)
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:745)
Thread(png-cruncher_5): queue not cleaned
while shutting downpng-cruncher_5
java.io.IOException: Stream closed
at java.lang.ProcessBuilder$NullOutputStream.write(ProcessBuilder.java:433)
at java.io.OutputStream.write(OutputStream.java:116)
at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
at java.io.BufferedOutputStream.flush(BufferedOutputStream.java:140)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:297)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at com.android.builder.png.AaptProcess.shutdown(AaptProcess.java:143)
at com.android.builder.png.QueuedCruncher$1.shutdown(QueuedCruncher.java:161)
at com.android.builder.tasks.WorkQueue.shutdown(WorkQueue.java:169)
at com.android.builder.png.QueuedCruncher.end(QueuedCruncher.java:309)
at com.android.builder.internal.aapt.v1.AaptV1.lambda$compile$0(AaptV1.java:430)
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:745)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.lang.RuntimeException: Crunching Cruncher launcher.png failed, see logs
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 4.213 secs
请帮我解决这个错误
谢谢
【问题讨论】:
看看这个答案***.com/questions/30111443/… 看我这里的回答,可能有帮助:***.com/a/44892542/3412127 【参考方案1】:在你的 gradle 文件中更改 buildtoolversion
android
compileSdkVersion 25
buildToolsVersion "25.0.0" // change here with your installed buildtool version
defaultConfig
applicationId "com.project.project"
minSdkVersion 10
targetSdkVersion 25
【讨论】:
【参考方案2】:我在 Debian 32bit 中修复了这个错误:
上传 Android SDK 构建工具 19.1 版
项目结构 -> 属性 -> 构建工具版本 19.1
然后项目构建没有错误
【讨论】:
【参考方案3】:用这个替换 build.gradle:
apply plugin: 'com.android.application'
android
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig
applicationId "com.project.project"
minSdkVersion 10
targetSdkVersion 25
buildTypes
release
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
dependencies
compile 'com.android.support:support-v4:25.0.0'
compile files('libs/httpmime-4.0.jar')
【讨论】:
以上是关于Gradle 构建错误(Android Studio 2.2.2)的主要内容,如果未能解决你的问题,请参考以下文章
Ionic Cordova 使用 Gradle 构建 Android 错误并且构建失败 [重复]
更新 Android Studio 后 Gradle 构建错误
使用 androiddeployqt 为 android 构建 Qt 应用程序时出现 Gradle 构建错误