This is the output of my Gradle console, I am unable to build my project
D:\\Android Projects\\....\\app\\src\\main\\res\\layout\\topic_view_header.xml
Error
Having the same issue here. As pointed out by @Izabela Orlowska, this problem is most likely caused by special characters in path (android grandle files, resources etc..).
For me: having ří
in folder name caused all the problems. Make sure you do not have any special characters in paths. Disabling AAPT2 is only a temporary "solution". Your project path contains non-ASCII characters android studio
I got same error AAPT2 error: check logs for details, and i applied above solutions, as per most common solution, i was opened gradle.properties and add line
android.enableAapt2=false
for solution, but i got an error Process 'command 'D:\Android\sdk\Sdk\build-tools\27.0.3\aapt.exe'' finished with non-zero exit value 1
But after many searches i found that there is problem in layout's xml file that i was repeat lines in layout's xml file which is as below:
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
Remove Repeat lines from xml file and rebuild project and Done.
Check following things in your project:
Make sure any XML file doesn't have blank space at starting of the file.
Make sure that any drawable file doesn't have any issue like capital letters or any special symbols in name.
If your aapt2.exe is missing continuously then please scan your full PC, May be there is a virus which is removing adb.exp or aapt2.exe
Hope you will get solution.
I fixed the ERROR with three steps
1. I checked for the problem SOURCE
2. Provided the correct string/text, it was the CAUSE
3. I cleaned the project, you will find it under BUILD.
Disabling the AAPT2 mght cause issue in further development, In my case the error was generated when I created the app icon.
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="108dp"
android:height="108dp"
android:viewportWidth="Infinity"
android:viewportHeight="Infinity">
<path android:fillColor="#26A69A"
android:pathData="M0,0h108v108h-108z"/>
<path android:fillColor="#00000000" android:pathData="M79,19L79,89"
android:strokeColor="#33FFFFFF" android:strokeWidth="0.8"/>
I solve it by removing this line
android:viewportWidth="Infinity"
android:viewportHeight="Infinity"
As suggested by others,
android.enableAapt2=false
is the most common solution.
But in my case, the error was due different versions in compileSdkVersion and buildToolsVersion.
Make sure that the major version is maintained the same.