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

后端 未结 30 1461
野的像风
野的像风 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条回答
  • I had a very similar problem. It was solved by deleting gradle's cache (~/.gradle/caches on linux), which forced android studio to re download and re generate everything.

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

    I also encountered this error. For me, it was when changing the target SDK from 26 down to 25. I was able to fix the problem by changing the appcompat dependency version from

    implementation 'com.android.support:appcompat-v7:26.1.0'

    to

    implementation 'com.android.support:appcompat-v7:25.4.0'

    This will allow the compiler to access the styling attributes that it is currently unable to find. This will actually fix the problem instead of masking the real issue as Enzokie suggested.

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

    If you've seen this error after trying to run individual Android implementation tests or test classes (by clicking on the run icon in the gutter) in a Kotlin project in Android Studio 3.0.1, you can get around the error by instead running the full test package (by right-clicking on the test package and choosing "Run tests in...").

    There is a known bug in Android Studio 3.0.1 that causes the IDE to run Kotlin implementation tests as regular JUnit tests, which caused the OP's error message to get shown on my machine. The bug is tracked at https://issuetracker.google.com/issues/71056937. It appears to have been fixed in Android Studio 3.1 Canary 7.

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

    I tried everything suggested on here and many other sites, I eventually figured out that the problem was with Bitdefender blocking aapt....

    If you have Bitdefender installed then you need to turn aapt & aapt2 "Application Access" on individually.

    Hope this is of use.

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

    I just had this problem when trying to use data bind and declaring the layout tag. I know it is a bit late but for the sake of anyone encountering this problem, What I did to resolve the issue after so many attempts was that on your root layout when you are not using data bind say for example this

      <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            tools:context=".MainActivity">     </android.support.constraint.ConstraintLayout>
    

    remove the

    xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            xmlns:tools="http://schemas.android.com/tools"
    

    and just put it on your layout tag(that is if you are using data binding)

    <layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools">
    
    </layout>
    

    and hopefully it will work. the android.enableAapt2=false didn't work for me so I have to remove everything and try to figure out why I get the error when I put layout tag and use data binding thus I came up with the solution. Hope it helps

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

    Since at some point in the future the support for AAPT(1) will be deprecated, it would be good to identify the reason for the error you reported.
    Could you provide the contents of the \app\src\main\res\layout\topic_view_header.xml file? From the question marks it is possible that you are using non-ASCII characters, which AAPT2 still has some trouble with. If it's indeed non-ASCII characters then please follow the bug on https://issuetracker.google.com/68262818.

    Update: The issue is fixed in android gradle plugin version 3.2.0-alpha11 or newer.

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