Exception: AAPT2 error: check log details

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? When migrating to gradle-plugin-3.0.0 I get this exception.

+59
source share
22 answers

This morning I ran into this problem and also found a solution. This problem occurs when you mess up one of your XML files. I suggest you look through them one by one and see the latest changes. This may be due to a stupid mistake.

In my case, I accidentally hardcoded the color string as #FFFFF (I know this is bad practice). As you can see, he had 5 F instead of 6. He did not show any warnings, but was the cause of the same problem that you encountered.

Edit 1: Another thing you can do is run the assembler in your Gradle console. It will find the specific row for you.

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

enter image description here

+157
source

AAPT2 Error Solution.

If your Android studio has been updated.

You may encounter an error in the studio, such as " AAPT Error 2: Check the log for details "

This error occurs when you have done something wrong in your XML file, for example, an invalid value, contents 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. This gives an error like AAPT2.

If you want to know where the real mistake is

Follow the step.

  1. Look at the panel to the right of your Android studio. Open the "Gradle" tab and click on it.
  2. You will see the option "application". Press here.
  3. In the application options you will see [Tasks β†’ build], click on it.
  4. After that, you will get a list of options and see a double click on "AssemblyDebug".
  5. Be patient and look at the "Assembly" tab on the bottom panel of Android studios, there you will get a specific error.

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

+36
source

The error may be caused by non-ASCII characters in the gradient path. For example, the Cyrillic characters of the user folder. Thus, the problem is solved only by moving to another directory with an ASCII-only path.

Troublesome gradle path

+11
source

I fixed the ERROR in three steps
1. I checked for a problem SOURCE
2. Provided the correct line / text because it was a REASON
3. I cleared the project, you will see it in the BUILD section.

enter image description here

+5
source

Just add this line according to your compileSdkVersion

 buildToolsVersion "27.0.3" 

Update Build Tools Version

+5
source

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

+3
source

You may have a problem with the png file, see here:

1 still called: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check the logs for more information in com.android.builder.png.AaptProcess $ NotifierProcessOutput.handleOutput (AaptProcess.java:454)

It can be a damaged image or a jpeg image with the extension png

+3
source

If you get this error only when you generate a signed Apk. Then the problem may be in one or more formats of the imported media files. I used the image directly from the network to the studio and could not generate an apk sign, then I found an error.

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

+3
source

Make sure that the image in the drawing folder is not damaged.

+3
source

I ran into a similar problem. Akilesh awasthi's answer helped me fix this. My problem was a little different. I used the places_ic_search icon from com.google.android.gms: play-services-location The latest version of com.google.android.gms: play-services-location: 15.0.0 does not provide the places_ic_search icon. Because of this, there was a problem in the layout.xml files. This caused the AAPT2 error to fail: check the logs for details as a message. Android studio should show cannot find drawable_search as a message instead.

As a result, I temporarily used a lower version of com.google.android.gms: play-services-location. Hope this helps someone in the future.

+2
source

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

Move the project to the desired workspace. Hope this helps someone in the future.

+2
source

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 } 
+2
source

fooobar.com/questions/1273785 / ...

Akhilesh Awasthi's answer was right for me. I scan my XML file and find out that in one of the TextView I set android:layout_height="20" without 'dp' . I don’t know why, but in Android Studio 3.1 Canary 6, if you are editing in the Designer tool, your user interface units have not been added to xml. This may be a Canary version error. Try to carefully examine all the elements in the recently edited xmls

+1
source

Just in case, the solution above did not work. In my case, Bitdefender Antivirus warned AAPT2 about making changes to a specific file.

+1
source

For me, I got this error while working on some Udacity projects. I fixed this 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() } } 
+1
source

If you are looking for a way to understand the essence of the problem. Android Studio contains a feature in the settings editing panel that simplifies this. By clicking on the tag "application" (usually it is to the left of the top launch button)

You will open the ability to edit configurations. From there, instantiate the gradle option for yourself.

The main functions are the gradient design as well as the task. Connect the task to the debugging initiative.

When you launch the application through this parameter, Android will spit out detailed errors (that we all would like to appear more often), and these errors will directly indicate what needs to be solved.

+1
source

I had this error and there is no meaningful message to tell me what was wrong. I finally deleted this line from gradle.properties and received a meaningful error message.

 android.enableAapt2=false 

In my case, one of the team changed the extension .jpg to .png , and the file header did not match the extension. Fun.

0
source

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

in

style="?android:attr/progressBarStyleSmall"

0
source

I also got the same error due to using the & character directly in the XML layout. Therefore, please be careful when using HTML entities in your project.

0
source

A possible problem with this may be with your XML files. I came across this when I deleted my files without xml problems.

To fix this error in the gradle.properties module add the following line:

 android.enableAapt2=false 

after adding this line restart gradle.

and clean up, rebuild your project.

-1
source

This solved the problem for me ... Build | Clear Refactor Project | Delete Unused Resources I'm still new to this, so I can't explain why this might work. It was an arbitrary choice on my part; it was simple, did not require detailed changes, and I just thought it might help :)

-1
source

some characters must be passed as '%'

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

Source: https://habr.com/ru/post/1273785/


All Articles