Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

后端 未结 30 1477
野的像风
野的像风 2020-11-22 12:51

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         


        
相关标签:
30条回答
  • 2020-11-22 13:38

    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

    0 讨论(0)
  • 2020-11-22 13:38

    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.

    0 讨论(0)
  • 2020-11-22 13:38

    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.

    0 讨论(0)
  • 2020-11-22 13:39

    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.

    0 讨论(0)
  • 2020-11-22 13:44

    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"
    
    0 讨论(0)
  • 2020-11-22 13:44

    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.

    0 讨论(0)
提交回复
热议问题