Issue while adding location service in build.gradle in android - android

I want to add this google play location services in android
implementation 'com.google.android.gms:play-services-location:17.0.0'
and my support:appcompat library is
implementation 'com.android.support:appcompat-v7:27.1.1'
targetSdkVersion is 27
compileSdkVersion is 27
when try to build getting error
Android resource linking failed
D:\AndroidStudioProject\GpsLocationApp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2015: error: resource android:attr/fontVariationSettings not found.
D:\AndroidStudioProject\GpsLocationApp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values\values.xml:2015: error: resource android:attr/ttcIndex not found.
error: failed linking references.

Google Play services and Firebase migrated to AndroidX in the latest release.
It means that you are using both, support libraries and androidx libraries.
You can:
migrate to androidx as described below
downgrade your google play services dependencies (but it is not a real solution because you have to migrate before or after)
You can check the official release notes:
Warning: This release is a MAJOR version update and breaking change.
The latest update to Google Play services and Firebase includes the following changes:
Migration from Android Support Libraries to Jetpack (AndroidX) Libraries. Libraries will not work unless you make the following changes in your app:
Upgrade com.android.tools.build:gradle to v3.2.1 or later.
Upgrade compileSdkVersion to 28 or later.
Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.
Also about the specific error described in the answer:
The error is:
AAPT: error: resource android:attr/fontVariationSettings not found.
AAPT: error: resource android:attr/ttcIndex not found
Change the compileSdkVersion to:
compileSdkVersion 28
fontVariationSettings and ttcIndex were added in api level 28.

Related

gradle not coordinated with the project

I am using android studio version 4.1.3 and gradle version 6.8.3 . My target sdk version for the project is API 26.
After clicking on sync the project, the result seems have no problem but after clicking on run app, I have some errors. One of them says,
gradle-6.8.3\caches\transforms-3\71de35e86c45a332199eb23f9129d32f\transformed\material-1.4.0\res\values\values.xml:1316:-1327:11: AAPT: error: style attribute 'android:attr/dialogCornerRadius' not found
I have seen the Error:(9, 5) error: resource android:attr/dialogCornerRadius not found
But again the problem is not solved
I don't know what should I do?

How to use Android material components with Support Library compatibility?

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.

Issues when upgrading support library to v28 or androidx

I am working on an Android project where I use:
com.android.tools.build:gradle 3.1.3
org.jetbrains.kotlin:kotlin-gradle-plugin 1.2.50
com.google.gms:google-services 3.2.0
compileSdkVersion 27
minSdkVersion 21
targetSdkVersion 27
com.google.dagger:dagger 2.12
com.google.dagger:dagger-android-support 2.12
com.android.support:appcompat-v7 27.1.1
The project is made using Kotlin and Databinding.
If I upgrade compileSdkVersion and targetSdkVersion to 28, project gets compiled.
But then when I try to upgrade to Androidx or AppCompat Library V7 28.0.0 and after fixing all dependencies, I usually end up getting following errors:
symbol: class DataBindingComponent
location: class SomeProjectClassBinding
e: /Users/a/project/databinding/SomeProjectClassBinding.java:76:
error: cannot find symbol
#Nullable DataBindingComponent component) { ...
I tried several things, including:
Using kapt "com.android.databinding:compiler" and also not using it. By default I have not that line since I read it is already included in Android Studio 3.2.
Although I am using Android Studio 2.3, I tried 3.3 Canary 13.
I tried upgrading com.android.tools.build:gradle to 3.3.0-alpha13
I tried removing org.gradle.jvmargs from gradle.properties.
I tried upgrading ext.kotlin_version to 1.2.71
I tried running gradle from terminal, so I can get the dependencies trees but I couldn't find anything inusual.
I tried to clean and rebuild project.
After upgrading all project's dependencies to the latest version, I do not get any warning from Android Studio but the project doesn't compiles because the error mentioned above.
So, is there anything I can do to know more why I am getting this databinding error ?, is there a sample project published where it is using:
Latest version of Android API, i.e. 28
Latest version of Support Library or Jetpack
Latest version of Dagger
Databinding
Kotlin
Also, do we know if the latests version of these are compatible with each other, like Android API 28 or Androidx with Dagger 2.17.

bringing down the target sdk and error syncing

In android studio, I am compiling against version 26.
However I decided to change the compile and target sdk to v23 but the issue is that I keep getting the error below upon sync gradle
Error:resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colored not found.
How can I get rid of it? It does not even point to lines of code
Thanks
This is probably because you have different version of compileSdkVersion and support library version. If you want to compile against version 23, you need to change your support library to version 23 too.
Your compileSdkVersion, buildToolsVersion, targetSdkVersion, and support library should use the same version.

No resource found that matches the given name (at 'android:src' with value '#drawable/abc_ic_menu_moreoverflow_mtrl_alpha')

I'm updating my project to API level 25 (Android 7.1.1).
I've updated the build.gradle file:
gradle plugin version
support library versions
targetSdkVersion
compileSdkVersion
When I sync the project, I get the following error:
Error:(2752, 34) No resource found that matches the given name (at android:src with value #drawable/abc_ic_menu_moreoverflow_mtrl_alpha).
The error mentions the root of the problem as android:src.
The abc_ic_menu_moreoverflow_mtrl_alpha is not used in my project. Perhaps it is being used in some library ... ??
What is the meaning of this, and how do I resolve this issue?
Does this require updating some other components such as the build tools or the Google repository?
I'm using Android Studio 2.3.2 and Gradle 3.3 if that helps.
This resource has renamed. Change this
abc_ic_menu_moreoverflow_mtrl_alpha
TO
abc_ic_menu_overflow_material Solve the issue.

Categories

Resources