我在Android Studio 3.0.1中创建了一个新项目,在构建过程中,我遇到了aapt2异常。禁用aapt2是一个选项,但我想了解为什么aapt2无法构建。
如果需要任何其他详细信息,请与我们联系
失败:构建因异常而失败。
出了什么问题: 任务':app:mergeDebugResources'。
的执行失败错误:java.util.concurrent.ExecutionException:com.android.tools.aapt2.Aapt2Exception:AAPT2错误:检查日志以获取详细信息
尝试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。
在1s内建立失败
AAPT warning(1028621614), Job(QueuedJob{
title=Compiling values.xml,
task={from=C:\Users\svssrinivas\AndroidStudioProjects\Learn\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml, to=C:\Users\svssrinivas\AndroidStudioProjects\Learn\app\build\intermediates\res\merged\debug},
future=com.google.common.util.concurrent.SettableFuture@7d83ce1d}): Done
Exception while processing job : QueuedJob{
title=Compiling values.xml,
task={from=C:\Users\svssrinivas\AndroidStudioProjects\Learn\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml, to=C:\Users\svssrinivas\AndroidStudioProjects\Learn\app\build\intermediates\res\merged\debug},
future=com.google.common.util.concurrent.SettableFuture@7d83ce1d} : com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Process (412248382) processed 0 files
Thread(queued-resource-processor_54): Process(412248382), after shutdown queue_size=2
Slave 1566465306 is ready
Process (197581388) processed 0 files
Thread(queued-resource-processor_55): Process(197581388), after shutdown queue_size=2
Process (1933852165) processed 1 files
Thread(queued-resource-processor_53): Process(1933852165), after shutdown queue_size=1
Process (1566465306) processed 0 files
Thread(queued-resource-processor_56): Process(1566465306), after shutdown queue_size=0
Shutdown finished in 9ms
Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
:app:mergeDebugResources FAILED
:app:mergeDebugResources (Thread[Task worker for ':',5,main]) completed. Took 0.561 secs.
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
* Try:
Run with --stacktrace option to get the stack trace. Run with --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
7 actionable tasks: 1 executed, 6 up-to-date
编辑:
完整的Gradle输出:
Executing tasks: [:app:assembleDebug]
Configuration on demand is an incubating feature.
Observed package id 'add-ons;addon-google_apis-google-19' in inconsistent location 'D:\AndroidSDK\add-ons\addon-google_apis-google-19-1' (Expected 'D:\AndroidSDK\add-ons\addon-google_apis-google-19')
Observed package id 'add-ons;addon-google_apis-google-19' in inconsistent location 'D:\AndroidSDK\add-ons\addon-google_apis-google-19-1' (Expected 'D:\AndroidSDK\add-ons\addon-google_apis-google-19')
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:checkDebugManifest UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources
values_values.arsc.flat: error: failed to open.
Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
:app:createDebugCompatibleScreenManifests
:app:processDebugManifest
:app:splitsDiscoveryTaskDebug
:app:prepareLintJar UP-TO-DATE
:app:compileDebugNdk NO-SOURCE
:app:mergeDebugShaders
:app:compileDebugShaders
:app:generateDebugAssets
:app:mergeDebugAssets
:app:mergeDebugJniLibFolders
:app:transformNativeLibsWithMergeJniLibsForDebug
:app:transformNativeLibsWithStripDebugSymbolForDebug
:app:processDebugJavaRes NO-SOURCE
:app:validateSigningDebug
:app:mergeDebugResources FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 24s
18 actionable tasks: 11 executed, 7 up-to-date
答案 0 :(得分:1)
简单的解决方案与文件夹权限有关。在经过堆栈跟踪输出并了解Java异常的更多信息之后,我发现了答案。
将您的Development / Project文件夹移动到一个提供对android studio / gradle的写访问权限的位置。