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:error: resource attr/?? (aka -packagename- :attr/??) not found.
Error:error: resource attr/?? (aka -packagename-:attr/??) not found.
Error:error: resource attr/?? (aka -packagename-:attr/??) not found.
Error:resource attr/?? (aka -packagename-:attr/??) not found.
Error:resource attr/?? (aka -packagename-:attr/??) not found.
Error:resource attr/?? (aka -packagename-:attr/??) not found.
Error:failed linking file resources.
Error:java.util.concurrent.ExecutionException:
java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:java.util.concurrent.ExecutionException:
com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for
details
Error:Execution failed for task ':app:processDebugResources'.
> Failed to execute aapt
Information:BUILD FAILED in 27s
Information:11 errors
Information:0 warnings
Android Studio 3.0 RC 2
In my case it was fixed by adding a reference to the constraint-layout package
If you are using Kotlin getting error because of some mistakes in xml files. In kotlin its very hard to find xml errors, build getting fail simply . To know the exact error log run below command in Android Studio Terminal and it is easy to fix the errors.
Sometimes ! be careful with property depth of the image ! and name for image
exemple : ic_xxxxx_xxxx - Copie
I had exactly the same issue: After updating to Android Studio 3.1.2 my project wouldn't compile with an AAPT2 error telling me some of my drawables which are referenced by
styles.xml
could not be found. Disabling AAPT2 isn't a solution anymore, since the setting is deprecated and will be removed at the end of 2018.Culprit was an empty line just before the xml decleration in a totally unrelated
layout.xml
file... So thelayout.xml
file started like this:Removed the empty line and everything worked like a charm again. Unbelievable and unlikely, but true.
Android Studio actually gave a warning because the file didn't start with the xml decleration (because of the empty line). But the warning is only visible when the file is opened in the editor.
Important Update
You can update your build gradle version in Project level
build.gradle
to latest.and gradle-wrapper.properties
That's All! Sync and Run, Bingo!
More info Android Documentation
If you add, you will get an warning
android.enableAapt2=false
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.