I have following dependencies in my app-level build.gradle file
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.android.support:design:27.1.1'
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'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.android.support:cardview-v7:27.0.2'
}
These works fine without any error. But, When I try to put a new third party dependency of CircleImageView implementation 'de.hdodenhof:circleimageview:2.2.0', the gradle build fails and there is error on implementation 'com.android.support:appcompat-v7:27.0.2' line saying All com.android.support libraries must use the exact same version.... I am wondering how this third party library creating problem in support libraries. What is wrong there?
That library is implementing support libraries as well, but different versions. Specifically, it uses the support-annotations 27.1.0 library.
There are two things you can do.
Update your dependencies. 27.0.2 is outdated. 27.1.0 is as well, but less so.
Exclude that library from your implementation and implement it yourself:
implementation ("de.hdodenhof:circleimageview:2.2.0") {
exclude group: "com.android.support" module: "support-annotations"
}
implementation 'com.android.support:support-annotations:27.1.1'
You should update all your support dependencies to 27.1.1.
The third party library internally uses the app compat library and because the version used by project is different from the library version, it gives the error. Updating appcompat, design and cardview dependencies to version 27.1.1 worked fine as follows.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.1.1'
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'
implementation 'com.android.volley:volley:1.1.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
}
If you want all support libraries including third party libraries internally use the same support library version, then add below code in your project level gradle
ext {
support_library_version = '27.1.1'
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "$support_library_version"
}
}
}
}
The support libraries should have the same version as the other dependencies which are related.
Change them to v 27.1.1 (The point is they should have the same version):
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
And then if you saw any errors which points to "should have same version", run :
./gradlew dependencies
To see which library is using old version.
Mostly, it can be fixed by adding the updated version of the library (same as the support library) in your build.gradle dependencies.
Related
I am having trouble in generating signed apk. Lint errors displayed on screen
Following error shows
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.0. Examples include 'com.android.support:animated-vector-drawable:28.0.0' and 'com.android.support:exifinterface:27.1.0'
Dependencies in build.gradle file is below:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
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'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
//picasso libraray
implementation 'com.squareup.picasso:picasso:2.71828'
//retrofit libraries
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.okhttp3:okhttp:4.3.1'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.5.0'
}
On this line
implementation 'com.android.support:appcompat-v7:28.0.0'
lint error occurred
AndroidX replaces the original support library APIs with packages in
the androidx namespace. Only the package and Maven artifact names
changed; class, method, and field names did not change.
Read official guideline about - Migrating to AndroidX. You should migrate to AndroidX.
With Android Studio 3.2 and higher, you can migrate an existing
project to AndroidX by selecting Refactor > Migrate to AndroidX from
the menu bar.
dependencies will be
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
Then add below in your build.gradle section.
android {
lintOptions {
checkReleaseBuilds false
abortOnError false
}
}
I found a error problem in build.gradle. Have a message to me "All com.android.support libraries must use the exact same version specification (mixing version can lead to runtime crashes). And there is a red line on the bottom of "implementation 'com.android.support:appcompat-v7:28.0.0'".I don't know where I went wrong.
Thank you
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation "com.android.support:appcompat-v7:28.0.0"
implementation "com.android.support:design:28.0.0"
implementation "com.android.support:design:28.0.0"
implementation 'com.android.support:palette-v7:28.0.0'
implementation "com.android.support:cardview-v7:28.0.0"
implementation "com.android.support:recyclerview-v7:28.0.0"
//Firebase Dependencies
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-firestore:18.0.1'
implementation 'com.google.firebase:firebase-database:16.0.6'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-ads:17.1.3'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-appindexing:17.1.0'
implementation 'com.google.firebase:firebase-ads:17.2.0'
implementation 'com.google.android.gms:play-services-ads:17.2.0'
implementation 'com.artjimlop:altex-image-downloader:0.0.4'
implementation 'com.yalantis:ucrop:2.2.0'
implementation 'com.github.danimahardhika:cafebar:1.3.1'
implementation 'com.github.qiugang:EditTag:v1.2.4-beta2'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.airbnb.android:lottie:2.6.0'
implementation 'com.github.chyrta:AndroidOnboarder:0.7'
//Error Fixer
implementation 'com.android.support:multidex:1.0.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'
Your gradle dependencies require rework:
Clean the duplicate dependencies and add each line only once!
Lines:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:design:28.0.0"
are twice. Keep each one only once!
Use only one version definition of each library. Firebase core has import of two different versions:
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.7'
Select one of the two lines.
Depenencies of your dependencies should not have different versions. You have many libraries that use other versions of com.android.support components, which can cause this error.
For example:
'com.artjimlop:altex-image-downloader:0.0.4' use com.android.support:appcompat-v7:23.1.0 see here
'com.yalantis:ucrop:2.2.0' use com.android.support:appcompat-v7:24.2.0 see here
'com.github.danimahardhika:cafebar:1.3.1' use com.android.support:design and com.android.support:cardview-v7 see here
'com.github.qiugang:EditTag:v1.2.4-beta2' use com.android.support:recyclerview-v7 and com.android.support:appcompat-v7 see here
etc the list goes on for almost all 3rd party github libraries.
You can use the following configuration in order to exclude all that dependencies.
configurations {
all*.exclude module: "appcompat-v7"
all*.exclude module: "recyclerview-v7"
all*.exclude module: "design"
all*.exclude module: "cardview-v7"
// ... etc in case there are extra dependencies
}
or even better you can get through each dependency and exclude the exact libraries that cause the duplication:
ie. for 'com.artjimlop:altex-image-downloader:0.0.4' you should change the implementation 'com.artjimlop:altex-image-downloader:0.0.4' with:
implementation ('com.artjimlop:altex-image-downloader:0.0.4') {
exclude group: 'com.android.support', module: 'appcompat-v7'
// for more than one just add it in a new line ie.
// exclude group: '<first part till : symbol>', module: '<second part between : symbol and version>'
}
Read this article here if you want to dig further regarding dependencies of dependencies issue.
You must be seeing red line like this right? hover your mouse pointer on red line and you will see dialog like this. find which libraries are still old (in my case it was cardview) add that library's latest version in gradle and your issue may be solved.
If still it doesn't then I am seeing that you are using old Firebase libraries, update them to latest too.
The error message is pretty clear, "All com.android.support libraries must use the exact same version specification". For example, you have this:
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.7'
You are trying to build 2 different versions, 16.0.1 and 16.0.7, of the same library. This can lead to runtime crashes. Choose which version you want to keep and delete the other. For example, if you want the version 16.0.7, replace these two lines with:
implementation 'com.google.firebase:firebase-core:16.0.7'
i tried all possible methods and it still did not sync please help. Below is my whole gradle file, i have tried to merge the firebase core and messaging but it still shows the error
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
implementation 'com.google.firebase:firebase-storage:16.0.4'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.firebaseui:firebase-ui-database:1.1.1'
implementation 'id.zelory:compressor:2.1.0'
implementation 'com.squareup.okhttp:okhttp:2.5.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.github.arturogutierrez:badges:1.0.5#aar'
implementation 'com.github.broakenmedia:CharCountTextView:v1.0'
implementation 'com.github.broakenmedia:MultiContactPicker:1.8.3'
implementation 'com.github.lguipeng:BubbleView:1.0.1'
implementation 'com.rockerhieu.emojicon:library:1.3.3'
implementation 'com.android.support:cardview-v7:27.1.1'
}
apply plugin: 'com.google.gms.google-services'
Below is the error message
Please fix the version conflict either by updating the version of the google-services plugin (information about the latest version is available at https://bintray.com/android/android-tools/com.google.gms.google-services/) or updating the version of com.google.android.gms to 16.0.4.
In your project build.gradle file, replace with below line:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
compile 'com.google.gms:google-services:4.2.0'//the latest version is 4.2.0
}
}
You are using different versions of firebase dependencies. That may be the reason for the failure. Update the google-services to latest version and use same version for firebase dependencies..
// as you can see different versions for firebase dependecies
implementation 'com.google.firebase:firebase-core:16.0.4'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-messaging:17.3.4'
implementation 'com.google.firebase:firebase-database:16.0.4'
Either use 16.0.4 or the latest version of firebase dependencies.
I had an Android project with gradle 2.2.0 and android-apt plugin 1.8. I had time to update it to newer tools gradle 3.1.0 and remove apt plugin to use newer proposed solution with implementation/CompileOnly and annotation processor keywords. After that project build/compile correctly and apk file is pushed to device but when I open class that uses: butterknife, tourguide, FancyToast or material-dialogs libraries class not see this dependencies (imports & references are marked in red).
Did anyone had the same issue?
Current dependencies:
dependencies {
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'
annotationProcessor "org.projectlombok:lombok:1.16.12"
compileOnly "org.projectlombok:lombok:1.16.12"
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
implementation ('com.github.worker8:tourguide:1.0.14-SNAPSHOT#aar') {
transitive = true;
}
implementation files('libs/greendao-2.1.0.jar')
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
//dagger
compileOnly 'javax.annotation:jsr250-api:1.0'
implementation 'com.google.dagger:dagger:2.0.2'
annotationProcessor 'com.google.dagger:dagger-compiler:2.0.2'
implementation('com.crashlytics.sdk.android:crashlytics:2.6.2#aar') {
transitive = true;
}
//save player objects (protect from removing it)
implementation 'com.google.code.gson:gson:2.7'
//permutation library
implementation 'com.googlecode.combinatoricslib:combinatoricslib:2.1'
//new toasts
implementation 'com.github.Shashank02051997:FancyToast-Android:0.1.3'
//tests
testImplementation 'junit:junit:4.12'
testImplementation "org.mockito:mockito-core:2.+"}
Project compiles/works but it is obstacle to work with this libraries
If your dependencies declared in different module you should use api instead of implementation
eg:
api 'com.google.dagger:dagger:2.0.2'
I'm trying to add firebase-auth:15.0.0 dependency to my project with appcompat-v7:27.0.0 but it causes a warning that "mixing versions can lead to runtime crashes".
I also tried to add new updated dependency of firebase-auth:15.1.0 but it causes the same issue.
Here is my dependencies block
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.google.firebase:firebase-auth:15.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'
}
You cannot upgrade to Version 27.1.0 as long as you are using libraries that run on lower versions. In your case, you simply have to "give in" and go for Version 26.1.0 (the lowest common denominator). You may upgrade to Version 27.1.0 once all libraries have been upgraded to 27.1.0.
Please try
implementation 'com.android.support:appcompat-v7:26.1.0'
Try this
implementation('com.google.android.gms:play-services-ads:15.0.1') {
exclude group: "com.android.support"
}
The error is been fixed here on this video https://youtu.be/Vjy_uv10t30
Or
add this //noinspection GradleCompatible
before
implementation 'com.android.support:appcompat-v7:28.0.0'
and synch.
That's all.