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 :).
Related
I am using a third party library ( cosmos calendar) and it have android.support dependency while i am using androidx for all my project .this caused a conflict, and this error on the gridLayout dependecy :
AAPT: error: duplicate value for resource 'attr/orientation' with config ''.
i remove gridlayout or the cosmos calendar dependency ,the project builds but can't build using both dependencies. how can i workaround this conflict ?
I ended up importing the whole cosmoCalendar library from github'since it is an open source project) migrating and refactoring it to work with AndroidX then packed it in a .aar file and add it as dependency in my project , everything then worked fine .
I try to use Android Material components library: https://github.com/material-components/material-components-android
For getting material date picker. After I add it to my gradle: implementation 'com.google.android.material:material:1.1.0-alpha09' and build project, I get error message:
Android resource linking failed
warn: removing resource
.../values.xml:3332: error: style attribute 'android:attr/dialogCornerRadius' not found.
.../values-v28.xml:15: error: resource android:attr/dialogCornerRadius not found.
.../values-v28.xml:19: error: resource android:attr/dialogCornerRadius not found.
.../values.xml:6855: error: resource android:attr/fontVariationSettings not found.
.../values.xml:6855: error: resource android:attr/ttcIndex not found.
.../values.xml:7134: error: resource android:attr/lineHeight not found.
.../values.xml:7139: error: resource android:attr/lineHeight not found.
.../values.xml:7354: error: resource android:attr/textFontWeight not found.
error: failed linking references.
As I know there are AndroidX and Support Library conflicts.
The library documentation states that migration to AndroidX is required.
How can I use this library without migration or maybe someone knows similar material date picker libraries?
You can find another material date picker library here. In order to resolve linking errors you can try following steps:
1) In gradle.properties file add the following code:
android.useAndroidX=true
android.enableJetifier=true
2) In app level build.gradle add the following code in buildTypes:
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
3) set compileSdkVersion and buildToolsVersion to 28.
The answer is inside the documentation.
If you don't want to switch over to the new androidx and com.google.android.material packages yet, you can use Material Components via the com.android.support:design:28.0.0 dependency.
Note: You should not use the com.android.support and com.google.android.material dependencies in your app at the same time.
You can find another library but keep in mind that other libraries like firebase or google play services today require the androidx migration. Sooner or later it will be the standard.
Please Help
When I connect my project file with fireBase the following error comes up.
null
resource style/TextAppearance.Compat.Notification.Info (aka com.kangkan.developer.f_c_m:style/TextAppearance.Compat.Notification.Info) not found.
resource style/TextAppearance.Compat.Notification (aka com.kangkan.developer.f_c_m:style/TextAppearance.Compat.Notification) not found.
resource style/TextAppearance.Compat.Notification.Time (aka com.kangkan.developer.f_c_m:style/TextAppearance.Compat.Notification.Time) not found.
resource style/TextAppearance.Compat.Notification.Title (aka com.kangkan.developer.f_c_m:style/TextAppearance.Compat.Notification.Title) not found.
failed linking references.
The Screen Shot
R class also showed error
I've cleaned the project, invalidate caches/restart,
It's not gone, I am using the firebase core implementation 'com.google.firebase:firebase-core:16.0.1'
This can result in several reasons.
Make sure you are using an updated version of android-gradle-plugin
Make sure there are no dependency version clashed in build.gradle file.
Check whether your XML resources don't have errors.
Hope this helps!
I had faced following error when I update versions in Gradle:
C:\Users\03142\.gradle\caches\transforms-1\files-1.1\appcompat-v7-27.1.1.aar\7e646e2ca904450b985ca981ac3ba677\res\values\values.xml
Error:(251, 5) error: duplicate value for resource 'attr/mode' with config ''.
Error:(251, 5) error: resource previously defined here.
How to Resolved it?
You have defined same resources for multiple times. Like you are using any module for your app but you initialled them multiple times in gradle file.
I use Android Studio 3.1.4 and android gradle plugin version 3.1.4.
Previously I set buildToolsVersion "27.0.3" in build.gradle of module and there was no problem in building/running. Today I installed newer version of build tools and change build.gradle to use that: buildToolsVersion "28.0.2"
But when I try to sync project with gradle files or rebuild project it ends with AAPT2 error:
AGPBI: {"kind":"error","text":"error: \u003citem\u003e inner element must either be a resource reference or empty.","sources":[{"file":"<path to module>/src/main/res/values/ids.xml","position":{"startLine":16,"startColumn":4,"startOffset":752,"endColumn":55,"endOffset":803}}],"original":"","tool":"AAPT"}
....
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':<modulee-name>:mergeDebugResources'.
> Error: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT2 error: check logs for details
But I do not understand what causes the error. For example addressed line in error is:
<item type="id" name="bookmark">false</item>
What causes this error and how I can solve this problem?
Edit
I added android.enableAapt2=false to the gradle.properties and it seems ignores error, but causes this warning:
The option 'android.enableAapt2' is deprecated and should not be used
anymore. Use 'android.enableAapt2=true' to remove this warning. It
will be removed at the end of 2018..
you cannot assign false (nor any other value but it's name) to an ID resource.
An ID is a simple resource that is referenced using the value provided in the name attribute (not the name of the XML file). As such, you can combine ID resources with other simple resources in the one XML file, under one element. Also, remember that an ID resources does not reference an actual resource item; it is simply a unique ID that you can attach to other resources or use as a unique integer in your application.
with android.enableAapt2=false it might ignore the logical error, but not "fix it".