When I add the core-ktx dependency to my app's build.gradle file, my gradle builds fail with the error message AAPT2 error: check logs for details
It furthermore tells that there are two attributes missing in values.xml
. This file is located under the .gradle folder inside my user directory.
when I add android.enableAAPT2=false
to my project properties, the build fails due to that option being deprecated so I want to avoid that.
The error descriptions of the two resource not found errors
are the following:
error: resource android:attr/fontVariationSettings not found. Message{kind=ERROR, text=error: resource android:attr/fontVariationSettings not found., sources=[C:\Users\Marc.gradle\caches\transforms-1\files-1.1\appcompat-v7-26.1.0.aar\b6d4f8d4d33639ae469eaec181e24176\res\values\values.xml], original message=, tool name=Optional.of(AAPT)}
When I add different ktx libraries everything is just fine. It builds properly and I can even import androidx.collections! How can I add the core-ktx library without any errors?
You are using 'AndroidX' which is only available if you set your compileSdkVersion 'android-P'
and targetSdkVersion 28
. Then in AndroidStudio go to Refactor -> Refactor to AndroidX
and everything should work fine now :).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With