Android Studio 3.1: mixing versions can lead to runtime crashes - android

Have recently upgraded to Android Studio 3.1, and at the same time I'm trying the Android P preview.
I'm getting the following error on compiling:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0-alpha1, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0-alpha1 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).
But I cannot see any instance of 26.1.0 anywhere. All I have in my gradle is:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
I've tried clearing caches, rebuilding app, etc. But error remains.

You need to override the conflicted libraries by adding the conflicted libraries to your dependencies block
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:customtabs:28.0.0-alpha1'
implementation 'com.android.support:support-vector-drawable:28.0.0-alpha1'
implementation 'com.android.support:support-media-compat:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'

The above warning is not specific to media-compat dependency. They just added example to explain the issue. The issue get resolved by adding v4 lib for me.
implementation 'com.android.support:support-v4:28.0.0'
in addition to
implementation 'com.android.support:appcompat-v7:28.0.0'
No need include
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'

You need to override the conflicted libraries by adding the conflicted libraries to your dependencies block. For example, from your error log you'll find the following:
Found versions 28.0.0-alpha1, 26.1.0. Examples include
com.android.support:animated-vector-drawable:28.0.0-alpha1 and
com.android.support:support-media-compat:26.1.0 less...
You can remove the error by adding the libraries with something like this:
dependencies {
implementation 'com.android.support:animated-vector-drawable:28.0.0-alpha1`
implementation 'com.android.support:support-media-compat:28.0.0-alpha1`
}

this error came,when i connect app to firebase.
no need to add any thing.
just put mouse cursor on error line(below one) and press Alt+Enter
(implementation 'com.android.support:appcompat-v7:28.0.0')
in the list enter first option.(noinspection)
After that it looks like this,
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'

Some dependency — perhaps playLicensing — has a transitive dependency on at least support-media-compat, for version 26.1.0.
To work around this:
Identify each Support Library artifact that shows up in "External Libraries" that is older than 28.0.0-alpha1. Based on the error, those older ones should all be 26.1.0, and it will be at least support-media-compat.
For each of those, add your own implementation line to your dependencies, requesting that artifact, but for 28.0.0-alpha1. This will cause Gradle to use the newer artifact, which happens to be what you want.
Hope that whatever is depending on those older artifacts will survive with the newer artifacts.
So, at minimum, you are adding:
implementation 'com.android.support:support-media-compat:28.0.0-alpha1'

In my case I resolved it by adding this below the error line.
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'

add in dependencies of build.grad (Module.app)
dependencies {
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
}

In my case adding support-v4 helped me to got loose of warning.
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
// other dependencies
}

Are you using a firebase in your project?
Using firebase core or firebase app indexing seem to be causing the problem.
I was having the same problem, but commenting on firebase packages makes the error to go away
// implementation 'com.google.firebase:firebase-core:16.0.8'
// implementation 'com.google.firebase:firebase-ads:17.2.0'
// implementation 'com.google.firebase:firebase-appindexing:17.1.0'

I think your gradle file has the below dependency. Add this to your app level build.gradle.
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:mediarouter-v7:28.0.0-alpha1'
implementation 'com.android.support:support-vector-drawable:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'

Related

Unresolved reference "Searcher"

Trying to integrate instant search in my Android app, but "Searcher" is unresolved.
I have the following dependencies currently, am I missing any?
implementation "com.algolia:algoliasearch-android:3.27.0"
implementation "com.algolia:algoliasearch-client-kotlin-jvm:1.0.0"
implementation 'com.algolia:instantsearch-androidx:1.15.2'
implementation "io.ktor:ktor-client-android:1.2.2"
include core dependency also
implementation 'com.algolia:instantsearch-androidx-core:1.15.2'
The latest release of instantsearch-androidx is lacking its transitive dependencies. The issue was reported on GitHub, you can follow its progress there - likely a new version will soon be released with the appropriate dependencies packaged.
As a workaround, you can add the dependencies yourself to your application - depending on the InstantSearch features you use, you might need some or all of the following:
implementation "com.algolia:instantsearch-androidx:$VERSION_INSTANTSEARCH"
implementation "com.algolia:instantsearch-androidx-core:$VERSION_INSTANTSEARCH"
implementation 'com.algolia:algoliasearch-android:3.27.0'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.github.bumptech.glide:glide:4.7.1'

After adding dependency "com.google.android.gms:play-services-location:15.0.1 " facing error to "com.android.support:appcompat-v7:28.0.0"

After adding dependency "com.google.android.gms:play-services-location:15.0.1 " it shows error to "com.android.support:appcompat-v7:28.0.0"
It shows that all com.android.support libraries must use the exact same version specification.
My dependencies are like below:
implementation fileTree(dir: 'libs', include: ['*.jar'])
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`
//GMS Services for location
implementation `com.google.android.gms:play-services-location:15.0.1`
The error is:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:media-compact-26.1.0.
If I remove gms dependency then the error for appcompact library has disappears. Any solutions will be appreciated.
Solution:
Add these lines in your gradle as dependencies
def support_libraries = "28.0.0"
implementation "com.android.support:appcompat-v7:$support_libraries"
implementation "com.android.support:design:$support_libraries"
implementation "com.android.support:support-compat:$support_libraries"
If this doesn't work, I'll suggest you an alternative solution.
Already answered in here : https://stackoverflow.com/a/52571055/4409113
Found versions 28.0.0, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0 and com.android.support:media-compact-26.1.0.
Try to add:
implementation 'com.android.support:support-media-compat:28.0.0'
In your Build.gradle dependencies.

Updating External Libraries in Android Studio

I'm fairly new to Android development, so apologies if this is obvious. I've searched quite a lot but am unable to resolve my issue.
In my build.gradle file I have the following section:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:26.1.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'
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.wdullaer:materialdatetimepicker:3.2.2'
}
However the line implementation 'com.android.support:appcompat-v7:26.1.0' is showing with a red squiggly line underneath and displaying the following message:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 26.1.0, 25.3.1. Examples include com.android.support:animated-vector-drawable:26.1.0 and com.android.support:support-v13:25.3.1 less... (⌘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).
I am unable to find out how to solve this issue. Building the project works fine and does not report any errors. I've tried doing File > Invalidate Caches / Restart but to no avail.
After doing a bit of searching I read that I can add implementation 'com.android.support:support-v4:26.1.0' to the build.gradle file and it should fix it, however the same error shows even after syncing.
This is an old project I made sometime last year and it doesn't have a lot in it, but I thought it would be better to learn how to resolve this issue rather than just creating a new project to get around it.
Try adding
implementation 'com.android.support:support-v13:26.1.0'
Although in your question, error is explaining everything, com.android.support:animated-vector-drawable:26.1.0 and com.android.support:support-v13:25.3.1 are not having same version.
Should always keep support libraries version same in build.grdale.
implementation "com.android.support:appcompat-v7:$support_lib_version"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation "com.android.support:design:$support_lib_version"
implementation "com.android.support:support-v4:$support_lib_version"
implementation "com.android.support:cardview-v7:$support_lib_version"
implementation "com.android.support:recyclerview-v7:$support_lib_version"
where support_lib_version is a constant.
ext { support_lib_version = '26.1.0'}
in same build.gradle file out side 'android' and 'dependencies'.

All com.android.support libraries must use the exact same version specification after adding firebase

My android Studio shows this error.
All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 27.1.1, 26.1.0. Examples include
com.android.support:animated-vector-drawable:27.1.1 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).
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.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'
implementation 'com.google.firebase:firebase-core:15.0.0'
Instead of downgrading or excluding the support library, you can solve the problem by overriding the support library. You can override the support library by adding the dependency which is in the error:
implementation "com.android.support:animated-vector-drawable:27.1.1"
For argumentation about this answer, you can see the following issues in Firebase:
Support Library out of date
com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/auth/api/signin/internal/zzf;
It themes like com.google.firebase:firebase-core:15.0.0 depends on older support library varsion (26.1.0).
There already is 15.0.2 version released, so you could try to:
use 15.0.2 version of firebase core. Probably it is based on latest support lib
ignore this message, as it is a warning, not an error, and probably your app would work fine with it. (not recommended, but could work)
downgrade your used support libs version to 26.1.0 so they are the same version. At least until google releases firebase based on the latest support lib version. (recommended way if #1 didn't work)
When you run ./gradlew :app:dependencies, you come to know the transitive dependencies of libraries one has included in their gradle.
From that hierarchy view, one can find out which libraries are depending on older versions and exclude them in gradle as shown below:
exclude group:'com.android.support'//as an example support library is excluded
As far as this question is concerned, it can be done like this:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.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'
implementation ('com.google.firebase:firebase-core:15.0.2'){
exclude group:'com.android.support'
}
Here support library is excluded as firebase core was depending on older versions, creating a conflict.
NOTE:
If your dependencies don't include the libraries that you have excluded but the dependency from which you have excluded needs it, you can add the excluded library in gradle with your compatible version.

FirebaseUI 3.1.2 dependency issue with firebase auth/firestore 11.8.0

I have seen this issue talked about on the FirebaseUI documentation but for the life of me I cannot understand the solution. I want to use the latest version of Firebase Auth and Firestore, as well as the latest version of FirebaseUI. Is this possible? Please do not just link me to the documentation of dependency issue, I would really appreciate an explanation of the documentation and what to actually write on my dependencies to fix this issue. I am tempted to just write my own UI, but firebaseUI is too good to pass up. Here are my dependencies right now:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:26.1.0'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.firebaseui:firebase-ui-auth:3.1.2'
}
With my past attempts at a fix I just tried lowering the versions of firebase..but that's not the solution I'm looking for and it usually just results in other errors. Thank you so much in advance!
EDIT: Here is error message: all gms/firebase libraries must use the exact same version specification(mixing versions can lead to runtime crashes). Found versions 11.8.0,11.6.2.
Examples include com.google.android.gms:play0services-base:11.8.0 and com.google.android.gms:play-services-auth:11.6.2.
{This error is, presumably, happening because firebaseui 3.1.2 is dependent on Firebase 11.6.2. But the version I am trying to use is 11.8.0}
You can exclude a dependencies' dependency with the exclude keyword.
implementation('com.firebaseui:firebase-ui-auth:3.1.2') {
exclude group: 'com.google.android.gms'
exclude group: 'com.google.firebase'
}
Firebase SDK Version 11.8.0 released December 18, 2017, and there is no officially released FirebaseUI version for that release for now. You can see the corresponding versions of Firebase UI - Firebase Services at https://github.com/firebase/FirebaseUI-Android
Corresponding FirebaseUI Version and Firebase/Play Services Versions are listed as:
3.1.2 --- 11.6.2
3.1.0 --- 11.4.2
3.0.0 --- 11.4.2
2.4.0 --- 11.4.0
...
This is why you get an error like :
all gms/firebase libraries must use the exact same version specification(mixing versions can lead to runtime crashes). Found versions 11.8.0,11.6.2. Examples include com.google.android.gms:play0services-base:11.8.0 and com.google.android.gms:play-services-auth:11.6.2.
Check if your
compile 'com.android.support:appcompat-v7:**26**.1.0'
version is same as your
targetSdkVersion **26**
Mine was different and changing this resolved the problem.

Categories

Resources