Exception : AAPT2 error: check logs for details

AndroidAndroid Gradle-Plugin

Android Problem Overview


Task :processDebugResources Failed to execute aapt com.android.ide.common.process.ProcessException: Failed to execute aapt
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:796)
    at com.android.build.gradle.tasks.ProcessAndroidResources.invokeAaptForSplit(ProcessAndroidResources.java:551)
    at com.android.build.gradle.tasks.ProcessAndroidResources.doFullTaskAction(ProcessAndroidResources.java:285)
    at com.android.build.gradle.internal.tasks.IncrementalTask.taskAction(IncrementalTask.java:109)
    at sun.reflect.GeneratedMethodAccessor200.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$IncrementalTaskAction.doExecute(DefaultTaskClassInfoStore.java:173)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:121)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:122)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:111)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:63)
    at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:197)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:107)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:124)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:80)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:105)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:99)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:99)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
    at java.lang.Thread.run(Thread.java:745) Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:482)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at com.android.builder.core.AndroidBuilder.processResources(AndroidBuilder.java:794)
    ... 47 more Caused by: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    at com.google.common.util.concurrent.AbstractFuture.getDoneValue(AbstractFuture.java:503)
    at com.google.common.util.concurrent.AbstractFuture.get(AbstractFuture.java:462)
    at com.google.common.util.concurrent.AbstractFuture$TrustedFuture.get(AbstractFuture.java:79)
    at com.android.builder.internal.aapt.v2.QueueableAapt2.lambda$makeValidatedPackage$1(QueueableAapt2.java:179)
    at com.android.builder.internal.aapt.v2.QueueableAapt2$$Lambda$489/579799618.run(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    ... 1 more Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
    at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:454)
    at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:411)
    at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:332)
    at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)

Where will the AAPT2 logs be saved? While migrating to gradle-plugin-3.0.0, I am getting this exception.

Android Solutions


Solution 1 - Android

I ran into this very issue today morning and found the solution for it too. This issue is created when you have messed up one of your .xml files. I'll suggest you go through them one by one and look for recent changes made. It might be caused by a silly mistake.

In my case, I accidentally hardcoded a color string as #FFFFF(Bad practice, I know). As you can see it had 5 F instead of 6. It didn't show any warning but was the root of the same issue as encountered by you.

Edit 1: Another thing you can do is to run assembleDebug in your gradle console. It will find the specific line for you.

Edit 2: Adding an image for reference to run assembleDebug.

enter image description here

Solution 2 - Android

AAPT2 Error solution.

If your Android studio has been updated.

Maybe, you would face an error in the studio like "AAPT 2 error: check the log for details"

This error will occur when you have done something wrong in your .xml file such as incorrect value, content not found, etc.

But, At that time you will not have the error specification there. Because the new version of Android Studio does not give you a specific error. It gives like AAPT2 error.

If you want to know where the actual error is then

Follow step.

> 1. Look at the panel which is at the right of your Android studio Check out the "Gradle" tab and click on it. > 2. You will see the "app" option. Click on it. > 3. In the app options you will see [Tasks -> build] click on it. > 4. Then you will get options list and see "assembleDebug" double click on it. > 5. Keep the patience and See build tab at the bottom panel of Android studios, you will get an exact error there what you made a mistake in which file and which position.

Click on assembleDebug and see log you can get the actual error is where

Solution 3 - Android

The error might be cause by non-ASCII symbols in gradle path. E.g. cyrillic symbols of the user folder. So, the problem is solved just by switching to another directory with ASCII-only path.

Troublesome gradle path

Solution 4 - Android

Just add this line as per your compileSdkVersion

buildToolsVersion "27.0.3"

Update Build Tools Version

Solution 5 - Android

You have a problem with a png file maybe, look here :

> 1 more Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 > error: check logs for details > at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:454)

It can be corrupted image or jpeg image with png extension

Solution 6 - Android

I fixed the ERROR with three steps

  1. I checked for the problem SOURCE
  2. Provided the correct string/text, because it was the CAUSE
  3. I cleaned the project, you ll see it under BUILD.

enter image description here

Solution 7 - Android

Check the latest edited XML file. It is the main Villian I had once such error, I then checked the last xml file, ther was a line like android:layout_marginTop="." I changed it to android:layout_marginTop="16dp". That fixed the bug!

Solution 8 - Android

I faced similar problem. Akilesh awasthi's answer helped me fix it. My problem was a little different. I was using places_ic_search icon from com.google.android.gms:play-services-location The latest version com.google.android.gms:play-services-location:15.0.0 does not provide the icon places_ic_search. Because of this there was a problem in the layout.xml files.That led to build failure AAPT2 error: check logs for details as the message. Android studio should be showing cannot find drawable places_ic_search as the message instead.

I ended up using a lower version of com.google.android.gms:play-services-location temporarily. Hope this helps someone in future.

Solution 9 - Android

I made a stupid mistake. In my case, I made the project path too deep. Like this: C:\Users\Administrator\Desktop\Intsig_Android_BCRSDK_AndAS_V1.11.18_20180719\Intsig_Android_BCRScanSDK_AndAS_V1.10.1.20180711\project\as\AS_BcrScanCallerSvn2

Please migrate the project to the correct workspace. Hope this helps someone in future.

Solution 10 - Android

If you are getting this error only when you are generating signed Apk . Then the problem might be in one or more of the imported media file format. I have used an image directly from net to studio and was not able to generate sign apk, then found the error .

> from Gradle >assembleRelease then got the error in console. see the error log in console image. This was my Error, See its clearly written that one of my image format is not valid or unknown

Solution 11 - Android

Ensure if no image in drawable folder is corrupted.

Solution 12 - Android

I tried every possible solution to fix this frustrating error and only below worked for me. In your build.gradle add this:

android {
    aaptOptions.cruncherEnabled = false
    aaptOptions.useNewCruncher = false  }

Solution 13 - Android

Just in case above solution did not work. In my case , Bitdefender Antivirus was Preventing AAPT2 from making change on certain file.

Solution 14 - Android

For me, I got this error while working on some Udacity projects. I fixed it by adding the following code to the top-level build.gradle file.

allprojects {
    String osName = System.getProperty("os.name").toLowerCase()
    if (osName.contains("windows")) {
        buildDir = "C:/tmp/${rootProject.name}/${project.name}"
    }
    repositories {
        jcenter()
        google()
    }
}

Solution 15 - Android

If you are seeking a way to get to the heart of the issue. Android studio contains a feature within the edit configurations panel that simplifies this possible. By clicking on the "app" tag (It is typically to the left of the top run button)

You will open the option to edit configurations. From there create an instance of the gradle option to yourself.

The core features are actually the gradle project as well as the task. Connect the task to your debug initiative.

When you run your app through this setting, Android will spit out detailed errors(That we all wish would appear more often) and these errros will point directly a what needs to be resolved.

Solution 16 - Android

I had this error and no meaningful message to tell me what was wrong. I finally removed this line from gradle.properties and got a meaningful error message.

android.enableAapt2=false

In my case somebody on the team had changed a .jpg extension to a .png and the file header didn't match the extension. Fun.

Solution 17 - Android

style="?android:attr/android:progressBarStyleSmall"

to

style="?android:attr/progressBarStyleSmall"

Solution 18 - Android

I was also getting same error because of using & character directly in layout xml. So, please be careful about using html entities in your project.

Solution 19 - Android

someone might get some help from my case I just put a hard coded color hex value without # like this by mistake android:textColor="FFA500" almost made me mad to findout. #FFA500 this solved my issue

Solution 20 - Android

Seeing your logs :

> at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > ... 1 more Caused by: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details > at com.android.builder.png.AaptProcess$NotifierProcessOutput.handleOutput(AaptProcess.java:454) > at com.android.builder.png.AaptProcess$NotifierProcessOutput.err(AaptProcess.java:411) > at com.android.builder.png.AaptProcess$ProcessOutputFacade.err(AaptProcess.java:332) > at com.android.utils.GrabProcessOutput$1.run(GrabProcessOutput.java:104)

I feel some PNG files are corrupted and were not parsed. Sometimes the images have an extension but are not real PNG.

You can check if the images in your project are real PNGs with the below command :

find . -type f -name "*.png" | xargs -L 1 -I{} file  -I {} | grep -v 'image/png; charset=binary$'

After getting the list use this site to convert them to PNG. Then check your build again.

Solution 21 - Android

this problem mostly about related xml typo mistakes, for me i just changed

       <EditText
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:hint="@string/str_search"
        android:background="@android:color/transparent"
        android:paddingLeft="10dp"/>

android:background="null"

to

android:background="@android:color/transparent"

Solution 22 - Android

DataBinding Error example (Error in xml attribute):

<layout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"     //<-- Remove this
    android:layout_height="match_parent" //<-- Remove this
>

</layout>

Solution 23 - Android

In my case, i had:

<string-array name="gilan">
   <item>Sowme'eh Sara</item>
</string-array>

and i'd changed it to:

<string-array name="gilan">
   <item>Sowme`eh Sara</item>
</string-array>

actually ' character was the problem and i'd changed it to ` (Backtick) character.

Solution 24 - Android

In my case I accidentally added to the last XML file that I was working on the encoding attribute Twice.
i.e:

<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?> <!--Remove this duplicate declaration!-->
.....
Rest of XML
.....

I strongly suggest checking if this is the cause since it took me quite a while to get over it because Android Studio can not point where is the problem.

Solution 25 - Android

possible issue related to this can be with your XML files. I have faced this when I deleted my unnecery xml files.

For remedy from this error in gradle.properties of the module, add this below line:

android.enableAapt2=false

after adding this line, restart the gradle.

and do once clean, rebuild your project.

Solution 26 - Android

This resolved the issue for me... Build|Clean project Refactor|Remove unused resources I am still a beginner at this so I cannot explain why this might have worked. It was an arbitrary choice on my part; it was simple, did not require detailed changes and I just thought it might help :)

Solution 27 - Android

some symbols should be transferred like '%'

<string name="test" formatted="false">95%</string>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDhanushView Question on Stackoverflow
Solution 1 - AndroidAkhilesh AwasthiView Answer on Stackoverflow
Solution 2 - AndroidPrince DholakiyaView Answer on Stackoverflow
Solution 3 - AndroidDmitry NevzorovView Answer on Stackoverflow
Solution 4 - AndroidMayur SojitraView Answer on Stackoverflow
Solution 5 - AndroidnasserView Answer on Stackoverflow
Solution 6 - AndroidBukunmi View Answer on Stackoverflow
Solution 7 - AndroidMohith7548View Answer on Stackoverflow
Solution 8 - Androidmohammed natharView Answer on Stackoverflow
Solution 9 - AndroidSancheView Answer on Stackoverflow
Solution 10 - AndroidFarhan SaikhView Answer on Stackoverflow
Solution 11 - AndroidbikramView Answer on Stackoverflow
Solution 12 - AndroidAndrainView Answer on Stackoverflow
Solution 13 - AndroidsolidfoxView Answer on Stackoverflow
Solution 14 - AndroidBeast77View Answer on Stackoverflow
Solution 15 - AndroidNVAView Answer on Stackoverflow
Solution 16 - AndroidGaBoView Answer on Stackoverflow
Solution 17 - AndroidtricknologyView Answer on Stackoverflow
Solution 18 - AndroidAvijitView Answer on Stackoverflow
Solution 19 - AndroidMithuView Answer on Stackoverflow
Solution 20 - AndroidAarth TandelView Answer on Stackoverflow
Solution 21 - AndroidAli OzkaraView Answer on Stackoverflow
Solution 22 - Android0 cęĥView Answer on Stackoverflow
Solution 23 - AndroidMohsentsView Answer on Stackoverflow
Solution 24 - AndroidJonathan ApplebaumView Answer on Stackoverflow
Solution 25 - Androidamit pandyaView Answer on Stackoverflow
Solution 26 - AndroidMickView Answer on Stackoverflow
Solution 27 - Androidyaoyue1019View Answer on Stackoverflow