I'm new to Android programming. When I tried to add material design library to
build.gradle it shows error under implementation 'com.android.support:appcompat-v7:28.0.0'.
Error message is :
Dependencies using groupId com.android.support and androidx.* can not be combined but found IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='support-fragment', myVersion='28.0.0', myPacking='aar', myClassifier='null'} and IdeMavenCoordinates{myGroupId='androidx.arch.core', myArtifactId='core-runtime', myVersion='2.0.0', myPacking='aar', myClassifier='null'} incompatible dependencies less... (Ctrl+F1)
Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion). Issue id: GradleCompatible
I don't want to remove appcompat since I want to support lower versions.
here is my gradle code:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
buildToolsVersion "29.0.0"
defaultConfig {
applicationId "com.vignesh.materialdesigntest"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "com.google.android.material:material:1.1.0-alpha07"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
In Android Studio, navigate to Refactor menu and select Migrate to AndroidX
You need to move to AndroidX
Go to android studio menu
Refactor
under this menu
Go to
Migrate to AndroidX
For more information AndroidX
Hope it will help !
Related
When I add implementation 'com.google.android.gms:play-services-ads:18.2.0' to my build.gradle, Android Studio highlights implementation 'com.android.support:appcompat-v7:28.0.0' with the error:
Dependencies using groupId com.android.support and androidx.* can not be combined but found IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='versionedparcelable', myVersion='28.0.0', myPacking='aar', myClassifier='null'} and IdeMavenCoordinates{myGroupId='androidx.interpolator', myArtifactId='interpolator', myVersion='1.0.0', myPacking='aar', myClassifier='null'} incompatible dependencies
My build.gradle is:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
configurations.all {
resolutionStrategy.force 'com.android.support:appcompat-v7:28.0.0'
}
defaultConfig {
applicationId "com.XXXXXX.XXXXXX"
minSdkVersion 14
targetSdkVersion 28
versionCode 3
versionName "1.1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
You are using
implementation 'com.google.android.gms:play-services-ads:18.2.0'
Google Play services migrated to AndroidX in the latest release.
Dependencies using groupId com.android.support and androidx.* can not be combined
It means that you are using both, support libraries and androidx libraries.
You can:
migrate to androidx as described below (in your case you have to migrate appcompat to implementation 'androidx.appcompat:appcompat:1.0.2')
downgrade your google play ads dependencies (but it is not a real solution because you have to migrate sooner or later)
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.
I have android studio 3.3.2 and my goal is to import the GraphView library but, it turns out that it has given me an error that all the libraries must have the same version specification, I present an image of the error
error Tooltip info
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 27.1.1. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:support-media-compat:27.1.1 less... (Ctrl+F1)
Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility
is compiling with a version of the Android support libraries that is not the
latest version (or in particular, a version lower than your targetSdkVersion). Issue id: GradleCompatible
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.mrl.fredy.estadistica"
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.jjoe64:graphview:4.2.2'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Instead of this
compileSdkVersion 28
targetSdkVersion 28
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
Use
compileSdkVersion 27
targetSdkVersion 27
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
GraphView library support library version is 27.
so you can downgrade your library version. if you do not want to downgrade then import GraphView as a module and in build.gradle file change to compileSdkVersion 28 and targetSdkVersion 28
Google says
"We recommend using the AndroidX libraries in all new projects. You
should also consider migrating existing projects to AndroidX as well."
source
but the Android Studio 3.2.1 still creates a new project templates which are supported by the historical "android.support.*" libraries.
Why?
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.developer.myapplication"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:support-vector-drawable:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
Not until Android Studio 3.3 or higher (currently still Preview/Beta).
If you create a new project with it, you'll find this Use AndroidX artifacts option. Then once created, you'll find that the dependencies are defaulted with androidx.*
I just created an Android project using Android Studio (v3.1.4) which consists of 1 activity: LoginActivity (generated from wizard).
Here's the content of my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "app.anta40.com.home_client_app"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support:design:28.0.0-rc01'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
I'd like to use Firebase Database, so I added this line on build.gradle:
implementation 'com.google.firebase:firebase-database:16.0.1'
Then Android Studio red-underlined the appcompat-v7 part, saying:
All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 28.0.0-rc01, 26.1.0. Examples include
com.android.support:animated-vector-drawable:28.0.0-rc01 and
com.android.support:support-media-compat:26.1.0 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that
are incompatible, or can lead to bugs. One such incompatibility is
compiling with a version of the Android support libraries that is not
the latest version (or in particular, a version lower than your
targetSdkVersion).
How to solve this?
There are incompatibility issues between your app compat which is: 'com.android.support:appcompat-v7:28.0.0-rc01' and firebase database version which is: 'com.google.firebase:firebase-database:16.0.1'.
One solution for this would be to use a lower targetsdk version like 27 and app compat, for example
implementation 'com.android.support:appcompat-v7:27.1.1'
I now have the following build.gradle Initially the compileSdkVersion and targetSdkVersion were set to 26 but I was getting a red line under
implementation 'com.android.support:cardview-v7:27.0.+'
implementation 'com.android.support:recyclerview-v7:27.0.+'
I then chaged compileSdkVersion and targetSdkVersion to 27, the red lines for the above two lines went away but now I have a red line under the following line
implementation 'com.android.support:appcompat-v7:27.0.2'
Below is my current
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.future.edge"
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.klinkerapps:android-smsmms:4.3.0'
implementation 'com.android.support:cardview-v7:27.0.+'
implementation 'com.android.support:recyclerview-v7:27.0.+'
}
apply plugin: 'com.google.gms.google-services'
What do you need to do to get rid of the red line under it?
implementation 'com.android.support:appcompat-v7:27.0.2'?
When I hover over it it says
All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 27.0.2, 25.2.0. Examples include
com.android.support:animated-vector-drawable:27.0.2 and
com.android.support:support-media-compat:25.2.0 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that
are incompatible, or can lead to bugs. One such incompatibility is
compiling with a version of the Android support libraries that is not
the latest version (or in particular, a version lower than your
targetSdkVersion.)
Current version of com.android.support:appcompat is 27.1.0.
Try this:
android {
compileSdkVersion 27
defaultConfig {
targetSdkVersion 27
}
dependencies {
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
}
Also it's not the best practice to use notation like "27.0.+" to specify versions. You don't have control over versions so between builds you can get different implementations. Such change can affect your code and you won't know what is the source of the problem.
Edit:
The problem is here:
compile 'com.klinkerapps:android-smsmms:4.3.0'
you are including whole project which has it's own versions and you just can't mix them. Check inside of this repo for versions or just build this as .aar file and include as library to your project.