0

I created a new project in Android Studio 3.0.1 and during the build process I am getting aapt2 exceptions. Disabling aapt2 is an option but I want to understand why aapt2 is failing to build.

Let me know if any additional details are required


Gradle Console Output:

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 1s


Console output with --info flag:

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

Edit:

Full Gradle Output:

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
solo_assassin
  • 483
  • 4
  • 20
  • That is not the full log, can you post the whole thing? No need to run with --info, if you look in the Gradle Console window there should be a stacktrace and above it there should be the messages from AAPT. – Izabela Orlowska Jan 24 '18 at 18:00
  • Hi, I am not able to access my computer today as I had to give it in for repairs. I will be able to post this info tomorrow. Thanks. – solo_assassin Jan 25 '18 at 03:55
  • @IzabelaOrlowska I have posted the entire gradle console output – solo_assassin Jan 26 '18 at 07:02
  • Hmm it looks like aapt2 had trouble compiling the merged values file. Can you post the contents of the file C:\Users\svssrinivas\AndroidStudioProjects\Learn\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml after the failed build? – Izabela Orlowska Jan 26 '18 at 13:36
  • @IzabelaOrlowska i have uploaded the values.xml file here. https://drive.google.com/file/d/1MLZFZsbgyBh4Y2sZk2KdneY87ah2kYvH/view?usp=sharing – solo_assassin Jan 29 '18 at 10:16
  • Hmm it looks correct. And you don't have any non-ascii characters in the path and the path seems to be of short enough length (<140 characters). I'm at a bit of a loss. Could you nagivate to the merged.dir/values directory and call "/build-tools//aapt2.exe compile -o . values.xml"? – Izabela Orlowska Jan 29 '18 at 11:45
  • I am getting this error "error: bad resource path (values.xml)." – solo_assassin Jan 29 '18 at 11:52
  • The command i ran was -- "D:\AndroidSDK\build-tools\27.0.3\aapt2.exe" compile -o . values.xml – solo_assassin Jan 29 '18 at 11:54
  • Okay can you try "(...)aapt2.exe compile -o . C:\Users\svssrinivas\AndroidStudioProjects\Learn\app\build\i‌​ntermediates\increme‌​ntal\mergeDebugResou‌​rces\merged.dir\valu‌​es\values.xml" (make sure the merged file exists before doing this). – Izabela Orlowska Jan 29 '18 at 11:54
  • Getting this:-- values_values.arsc.flat: error: failed to open. -- the file values.xml exists. – solo_assassin Jan 29 '18 at 11:57
  • Can you edit the values.xml file in the merged directory to contain only "bar" and try again? Also, can you check if you have enough space on your drive C? – Izabela Orlowska Jan 29 '18 at 12:12
  • same error:- values_values.arsc.flat: error: failed to open – solo_assassin Jan 29 '18 at 12:18
  • yes, my C:\ drive has around 30GB of free space – solo_assassin Jan 29 '18 at 12:18
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/164087/discussion-between-izabela-orlowska-and-srin). – Izabela Orlowska Jan 29 '18 at 12:21

1 Answers1

1

The simple solution has to do with folder permissions. I discovered the answer after a lot of digging through the stacktrace output and learning more about the Java exception.

Move your Development/Project folder to a location that gives write accesss to android studio/gradle.

Samuel Liew
  • 76,741
  • 107
  • 159
  • 260