How to resolve all google play-services dependencies with gradle? - android

Situation
Today, after touching nothing of the project, my gradle yelled at me and wouldn't compile the project. It failed to resolve firebase-iid, firebase-common, play-services-analytics-impl, play-services-auth-api-phone, and play-services-auth-base. So quite a mess after the weekend.
So I checked the versions of the different APIs, and upgraded the ones that needed upgrading, found out that Google had added a mandatory dependency to firebase-core, added it, then upgraded my google-services plugin, and even added a play-services-base dependency. I also upgraded firebase-messaging to version 17.0.0, and crashlytics to version 2.9.3.
But still, the build doesn't compile, with this error message:
The library com.google.android.gms:play-services-measurement-base is being requested by various other libraries at [[15.0.2,15.0.2], [15.0.4,15.0.4]], but resolves to 15.0.4. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
Gradle Files
Here is my Gradle file (showing dependencies part only), after my attempted fixes:
apply plugin: 'com.android.application'
...
dependencies {
implementation project(':library')
implementation project(':otherlibrary')
implementation 'com.android.volley:volley:1.1.0'
implementation('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
implementation 'org.apache.httpcomponents:httpclient-android:4.3.5'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-analytics:15.0.2'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation('com.google.android.gms:play-services-ads:15.0.1') {
exclude group: 'com.android.support', module: 'customtabs'
}
implementation 'com.google.android.gms:play-services-identity:15.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.android.gms:play-services-drive:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.readystatesoftware.sqliteasset:sqliteassethelper:2.0.1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.nineoldandroids:library:2.4.0'
implementation 'com.daimajia.slider:library:1.1.5#aar'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:exifinterface:27.1.1'
implementation 'com.android.support:support-v13:27.1.1'
// https://mvnrepository.com/artifact/com.darwinsys/hirondelle-date4j
implementation group: 'com.darwinsys', name: 'hirondelle-date4j', version: '1.5.1'
// For RxAndroid and RxJava
implementation 'io.reactivex.rxjava2:rxandroid:2.0.2'
// Because RxAndroid releases are few and far between, it is recommended you also
// explicitly depend on RxJava's latest version for bug fixes and new features.
// (see https://github.com/ReactiveX/RxJava/releases for latest 2.x.x version)
implementation 'io.reactivex.rxjava2:rxjava:2.1.12'
// Crashlytics
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.3'
// CSV with outputstream writer
implementation 'com.opencsv:opencsv:4.1'
// Gson
implementation 'com.google.code.gson:gson:2.8.5'
debugImplementation 'com.android.support.test:runner:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test:rules:1.0.2'
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
androidTestImplementation 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
And my project-wide gradle contain these lines:
...
repositories {
maven {
url 'https://maven.google.com/'
name 'Google'
}
...
}
dependencies {
...
classpath 'com.google.gms:google-services:4.0.1'
}
...
Official solution doesn't work
I already tried to fix the version number of multiple libraries according to the official firebase documentation, which is more or less the same as this question.
As you can read in the official documentation link, as of May 2nd, 2018, they offered a way to fix this kind of issue, but the numbers of the versions in question are not the same, and I already tried the given fix (with some downgrades now), to no avail.
Official documentation:
If your app has a dependency on com.google.firebase:firebase-core:15.0.0 as well as any of the following libraries:
com.google.android.gms:play-services-analytics
com.google.android.gms:play-services-appinvite
com.google.android.gms:play-services-tagmanager
com.google.firebase:firebase-analytics
com.google.firebase:firebase-crash
com.google.firebase:firebase-dynamic-links
com.google.firebase:firebase-messaging
You will need to update the version of the latter dependency to
15.0.2. This addresses the issue where version 3.3.0 of the Google Services Gradle plugin reports: The library
com.google.android.gms:play-services-measurement-base is being
requested by various other libraries at [[15.0.0,15.0.0],
[15.0.2,15.0.2]], but resolves to 15.0.2...
So how can I resolve these conflicts of versions in order for my build to compile once again correctly?

So after a day lost in this issue, I found out that the latest version of play-services-analytics is not the one they have published in their website. It is 16.0.0 and not 15.0.2.
Android Studio told that to a colleague as a warning, but mine was unconcerned about it. So here it is, the line that changes everything:
implementation 'com.google.android.gms:play-services-analytics:16.0.0'

I added this to my build.gradle (application version) and it worked:
googleServices { disableVersionCheck = true }
(Keep in mind that this is just to disable the version check, it does not actually fix anything)

I tried reverting back to an old build, and it seemed to work, what i found was that the gradle-wrapper.properties was using and older version (4.5) instead of the 4.6 i had in the newer project. Changing this as well as reverting to classpath 'com.android.tools.build:gradle:3.2.0-alpha08' from alpha15 seemed to do the trick. I think you can use the alpha 15 if you like, but to be sure you can use the classpath 'com.android.tools.build:gradle:3.1.2'.
Along with all these changes the firebase-core and the google-gms-services should be set to version 16.0.0.

Unfortunately google play service has been stopped
This widows msg are generated &never run any google service performs

Related

Could not determine the dependencies of task ':app:compileDebugJavaWithJavac' Flutter

When I start my flutter app, Im getting this error:
Could not determine the dependencies of task ':app:compileDebugJavaWithJavac'.
> In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[19.0.
2]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.
My dependencies in build gradle:
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.google.android.gms:play-services-basement:17.4.0'
implementation 'com.google.firebase:firebase-analytics:18.0.0'
implementation 'com.google.firebase:firebase-crashlytics:17.3.0'
implementation 'com.google.firebase:firebase-perf:19.0.10'
implementation 'com.google.firebase:firebase-database'
}
apply plugin: 'com.google.gms.google-services'
Please help me) Thanks in advance
To prevent versioning conflicts between Firebase SDKs, I recommend using the Firebase Bill of Materials (BoM) to manage the versions.
With the BoM, you'd have the following dependencies for Firebase:
dependencies {
implementation platform('com.google.firebase:firebase-bom:26.2.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-perf'
implementation 'com.google.firebase:firebase-database'
}
So as you can see, the only version we specify is for the Bill of Materials itself This in turn then specifies the (compatible) versions of the specific product SDKs.

Incompatible gradle versions - Android

My gradle file is not throwing any error while building. But, when I run Android lint, it fails with incompatible gradle version error.
Sharing the error:
Incompatible Gradle Versions
../../build.gradle: All com.google.android.gms libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 16.0.2, 16.0.1, 16.0.0, 15.1.0, 15.0.1. Examples include com.google.android.gms:play-services-measurement-base:16.0.2 and com.google.android.gms:play-services-measurement-api:16.0.1**
Sharing the google dependencies defined in app level gradle:
compile 'com.android.support:appcompat-v7:27.1.1'
compile 'com.android.support:gridlayout-v7:27.1.1'
compile 'com.android.support:design:27.1.1'
compile 'com.android.support:recyclerview-v7:27.1.1'
compile 'com.android.support:cardview-v7:27.1.1'
compile 'com.android.support:preference-v14:27.1.1'
compile 'com.android.support:support-annotations:27.1.1'
compile 'com.android.support.constraint:constraint-layout:1.1.3'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-analytics:16.0.0'
compile 'com.google.android.gms:play-services-auth:16.0.0'
compile 'com.google.firebase:firebase-core:16.0.3'
compile 'com.google.firebase:firebase-messaging:17.3.0'
compile 'com.google.code.gson:gson:2.8.2'
Project level gradle file:
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:1.5.0'
Which dependency making this lint error? How to solve this gradle incompatibility issue?
I have tried changing all google gms versions to 15, but it didn't solved the issue..
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-analytics:15.0.2'
compile 'com.google.android.gms:play-services-auth:15.0.1'
It happens because you are using an old plugin
classpath 'com.google.gms:google-services:1.5.0'
and different versions of the Google Services libraries.
You should update the Google Services Gradle Plugin:
dependencies {
classpath 'com.google.gms:google-services:4.2.0'
// ...
}
Then update your dependencies but it not necessary to use the same version.
Starting from plugin 3.3.0 there is a different behaviour:
Google Play services libraries after 15.0.0 now have independent
version numbers which follow SemVer. This change will allow for more
frequent, flexible updates by individual components. The Google
Services Gradle plugin has been updated to version 3.3.0 to support
this change in versioning.
Check also the documentation:
REMOVE THIS OLD PATTERN:
buildscript {
ext {
play_version = '15.0.0'
}
}
dependencies {
// DON’T DO THIS!!
// The following use of the above buildscript property is no longer valid.
implementation "com.google.android.gms:play-services-ads:${play_version}"
implementation "com.google.android.gms:play-services-auth:${play_version}"
implementation "com.google.firebase:firebase-firestore:${play_version}"
}
Now each dependency that you use may now be at different versions.
You need to update gradle build tools to this version:-
classpath 'com.android.tools.build:gradle:3.2.1'
and google play services
classpath 'com.google.gms:google-services:3.2.0'
The error message
All com.google.android.gms libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 16.0.2, 16.0.1, 16.0.0, 15.1.0, 15.0.1.
is very clearly telling that
This is what you have right now:
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-analytics:16.0.0'
it must be:
compile 'com.google.android.gms:play-services-location:16.0.2'
compile 'com.google.android.gms:play-services-maps:16.0.2'
compile 'com.google.android.gms:play-services-analytics:16.0.2'
Also, try to always use the latest version of Google APIs.
Hope this will help you.
adding to #Nouman Ch answer , These are the latest dependencies
implementation 'com.google.android.gms:play-services-location:16.0.0'
implementation 'com.google.android.gms:play-services-maps:16.1.0'
implementation 'com.google.android.gms:play-services-analytics:16.0.6'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
check here and here for finding latest versions
Go to project view of android studio. There in .idea> libraries you'll find libraries with versions 16.0.2, 16.0.1, 16.0.0, 15.1.0, 15.0.1.
These libraries are imported as dependencies of the ones you have in your build.gradle file. Import the latest versions of those libraries in your dependencies to remove the error.

The library com.google.firebase:firebase-analytics is being requested by various other libraries

I am getting this error when updating the Firebase libraries:
The library com.google.firebase:firebase-analytics is being requested
by various other libraries at [[15.0.1,16.0.0), [16.0.1,16.0.1],
[16.0.1,99999]], but resolves to 16.0.1. Disable the plugin and check
your dependencies tree using ./gradlew :app:dependencies.
Dependencies are:
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-messaging:17.1.0'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-appindexing:16.0.1'
implementation 'com.google.firebase:firebase-crash:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-invites:16.0.1'
implementation 'com.google.firebase:firebase-config:16.0.0'
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-firestore:17.0.2'
Is there a simple way to find the correct configuration?
If not, what plugin is to be disabled and how? if i just run the task i get the same error.
Update:
i think this dependency has something to do it with, because if disable it's pluging the depedency task runs:
implementation 'com.google.android.gms:play-services-auth:15.0.1'
Try using these steps:
Update your implementation versions (for the newest firebase versions see the release notes https://firebase.google.com/support/release-notes/android)
Update your project build.gradle file with the newest google-services version (at the moment classpath 'com.google.gms:google-services:4.0.1)
Or see this similar post

Failed to resolve: com.google.firebase:firebase-core:15.0.0

I have a strange issue when integrate firebase:
if you integrate firebase automatically from tools,
The new version of android studio have strange bug, the software inserts
implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
instead of
implementation 'com.google.firebase:firebase-database:16.0.1'
fix this line (remove numbers after last ':')
Remove the
implementation 'com.google.firebase:firebase-database:16.0.1:15.0.0'
and add only
implementation 'com.google.firebase:firebase-database:16.0.1'
Because 16.0.1 is added by our self and while after that we connect firebase using the plugin in the studio, it adds a new lib file with 15.0.0.
So that's not required.
Step 1 :
In your root build.gradle file add the repo:
allprojects {
repositories {
google()
maven { url "https://maven.google.com" }
}
}
Now Sync Gradle. This is the directory that contains the repos of Firebase.
Step 2 :(if step 1 doesn't works)
If the Step 1 doesn't works, then it should be because you are using the Gradle in offline mode. If your gradle is set to offline, android studio searches for the cached copies of the dependencies that you want to update and throws an error since it hasn't downloaded the file before.
Go to Settings >> Build, Execution, Deployment >> Gradle.
In the Global Gradle Settings section, disable Offline mode.
Now Sync Gradle again.
Use implementation com.google.firebase:firebase-database:16.0.1 as many wrote before. But also add the line: kapt com.google.firebase:firebase-database:16.0.1:15.0.0
this way firebase keep "Dependencies set up correctly".
after
implementation com.google.firebase:firebase-database:16.0.1
kapt 'com.google.firebase:firebase-database:16.0.1:15.0.0'
add the kapt, it fixed for me
Updated all the dependencies to
dependencies {
implementation "com.google.android.gms:play-services-base:16.0.1"
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'com.google.android.gms:play-services-location:16.0.0'
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'
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:16.0.6'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.5'
}
then build -> clean project, build -> rebuild project and is working

Error:Program type already present: android.arch.lifecycle.LiveData

When I press the run button in Android Studio, my app compiles but shows this error (redacted):
Error:Program type already present: android.arch.lifecycle.LiveData
(Full log)
I've tried deleting the .gradle folder, then going to Build > Clean Project and Build > Rebuild Project. However, it doesn't work. I've also tried deleting the source code, then cloning again from git and importing the folder to Android Studio. However, it still produces that error.
Here's my app's app/build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.edricchan.studybuddy"
minSdkVersion 24
targetSdkVersion 27
versionCode 8
versionName "1.0.0-rc.503"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
resConfigs "en"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:support-annotations:27.1.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
testImplementation 'junit:junit:4.12'
// Firebase stuff
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.android.gms:play-services-auth:11.8.0'
implementation 'com.firebaseui:firebase-ui-auth:3.1.0'
implementation 'com.firebaseui:firebase-ui-firestore:3.1.0'
implementation 'com.firebaseui:firebase-ui-storage:3.1.0'
// Provide a way to update the app
implementation 'com.github.javiersantos:AppUpdater:2.6.4'
// Chrome Custom Tabs
implementation 'com.android.support:customtabs:27.1.0'
// The app's intro screen
implementation 'com.heinrichreimersoftware:material-intro:1.6.2'
// Use for new Material Text field boxes recently introduced
implementation 'com.github.HITGIF:TextFieldBoxes:1.3.7'
// Report an issue to Github without having to open a new tab and so on...
implementation 'com.heinrichreimersoftware:android-issue-reporter:1.3.1'
}
apply plugin: 'com.google.gms.google-services'
Apparently, this is intended behavior:
com.firebaseui:firebase-ui-firestore:3.1.0 depends on android.arch.lifecycle:extensions:1.0.0-beta1. Switching to version 3.2.2 fixes the issue by using the Lifecycle 1.1 libraries that Support Library 27.1.0 are built upon. - Issue Tracker
For me, removing the firebase-ui dependencies solved the issue since I wasn't even using the library in the first place.
I had the very same problem today when I raised the support library version.
Try to replace all '27.1.0' with '27.0.2'
Later on I did manage to remove the error by upgrading other libraries as well.
THis is my current working state:
root gradle:
buildscript {
ext.kotlin_version = '1.2.21'
ext.support_version = '27.1.0'
ext.anko_version = '0.10.4'
ext.android_plugin_version = '3.0.1'
ext.google_services_version = '11.8.0'
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
classpath 'com.android.tools.build:gradle:3.1.0-beta4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.1'
}
}
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
//////////////////
app gradle libraries:
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1#aar') {
transitive = true
}
// kotlin:
implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
implementation "org.jetbrains.anko:anko-common:$anko_version"
implementation "org.jetbrains.anko:anko-commons:$anko_version"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:0.22.3'
// support libraries:
implementation "com.android.support:recyclerview-v7:$support_version"
implementation "com.android.support:support-v4:$support_version"
implementation "com.android.support:design:$support_version"
implementation "com.android.support:appcompat-v7:$support_version"
implementation "com.android.support:cardview-v7:$support_version"
implementation "com.android.support:support-vector-drawable:$support_version"
// misc:
implementation 'com.github.d-max:spots-dialog:0.7#aar'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.0-beta5'
implementation 'com.backendless:backendless:4.4.0'
implementation 'io.nlopez.smartlocation:library:3.3.3'
// Google services:
implementation "com.google.firebase:firebase-core:$google_services_version"
implementation "com.google.firebase:firebase-auth:$google_services_version"
implementation 'com.firebaseui:firebase-ui-auth:3.2.2'
implementation "com.google.android.gms:play-services-location:$google_services_version"
implementation "com.google.android.gms:play-services-auth:$google_services_version"
implementation('com.google.api-client:google-api-client:1.23.0') {
exclude group: 'com.google.code.findbugs', module: 'jsr305'
}
}
///////////////
I also upgraded graddle-wrapper.properties to:
#Wed Dec 20 15:08:34 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
This post is the top search result for the very similar error: "Program type already present: android.arch.lifecycle.ViewModelProvider$Factory"
My project uses Room and LiveData, but not firebase. The following changes removed the error:
FROM:
implementation 'android.arch.persistence.room:runtime:1.0.0'
annotationProcessor 'android.arch.persistence.room:compiler:1.0.0'
implementation 'android.arch.lifecycle:extensions:1.0.0'
annotationProcessor 'android.arch.lifecycle:compiler:1.0.0'
TO:
implementation 'android.arch.persistence.room:runtime:1.1.1'
annotationProcessor 'android.arch.persistence.room:compiler:1.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.1'
annotationProcessor 'android.arch.lifecycle:compiler:1.1.1'
--- UPDATED ANSWER ---
My previous answer was aimed at solving this error. However, I thought it would be worth presenting it again using best practises:
App level build.gradle file:
// Room components
implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
annotationProcessor "android.arch.persistence.room:compiler:$rootProject.roomVersion"
androidTestImplementation "android.arch.persistence.room:testing:$rootProject.roomVersion"
// Lifecycle components
implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleVersion"
annotationProcessor "android.arch.lifecycle:compiler:$rootProject.archLifecycleVersion"
Project level build.gradle file:
ext {
roomVersion = '1.1.1'
archLifecycleVersion = '1.1.1'
}
Reference:
https://codelabs.developers.google.com/codelabs/android-room-with-a-view/#2
Firebase-UI 3.1.0 isn't compatible with Firebase / Google Services 11.8.0
You will need to upgrade or downgrade according to https://github.com/firebase/FirebaseUI-Android#compatibility-with-firebase--google-play-services-libraries
Firebase-UI 3.1.0 with Firebase / Google Services 11.4.2
Firebase / Google Services 11.8.0 with Firebase-UI 3.1.3
Hope this help ;)
I also had the error posted in the original question, namely:
Error:Program type already present: android.arch.lifecycle.LiveData
It wasn't clear which libraries were causing the problem. With a hint from #lienmt above I realized that it may be related Firebase.
In my case, I am using Firebase and was also using firebase-ui library 3.2.2:
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
I had upgraded all my other Firebase libraries to 15.0.0 but realized my firebase-ui library was incompatible and confirmed it here:
https://github.com/firebase/FirebaseUI-Android#compatibility-with-firebase--google-play-services-libraries
Be sure to match your firebase-ui version to the exact Firebase versions that for which they are fixed for pairing.
Bumping my firebase-ui version to 3.3.1 was what resolved the error:
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
For reference here are the versions I'm using now and my app is running with no errors:
implementation 'com.google.android.gms:play-services-wearable:15.0.0'
implementation 'com.google.android.gms:play-services-auth:15.0.0'
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'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.google.firebase:firebase-database:15.0.0'
implementation 'com.google.firebase:firebase-core:15.0.0'
implementation 'com.google.firebase:firebase-auth:15.0.0'
implementation 'com.google.firebase:firebase-messaging:15.0.0'
implementation 'com.firebaseui:firebase-ui-database:3.3.1'
Please add following dependencies in your app build.gradel file
implementation "android.arch.core:runtime:1.1.1"
implementation "android.arch.core:common:1.1.1"
#Edric: since I couldn't replay with images in the thread I am answering your question here.
Changes that worked for me:
PS: I also upgraded distributionUrl in gradle-wrapper.properties to
http://services.gradle.org/distributions/gradle-4.6-all.zip
Like Edric mention, this happens because some library still use the old version of android.arch.lifecycle:extensions library, that is android.arch.lifecycle:extensions:1.0.0.
One way to handle this is by forcing the app to use the same version of that library (and if we can, use the newest one).
There are two ways to do that:
Explicitly defined the library version that we want to use in our Gradle, under dependencies section.
implementation 'android.arch.lifecycle:extensions:1.1.1
or
Force resolution of the library, also under dependencies section.
android {
configurations.all {
resolutionStrategy.force 'android.arch.lifecycle:extensions:1.1.1'
}
}
In my case, bumping targetSdkVersion and compileSdkVersion to 28, as well as using version 28 of all support libraries fixed the issue.
I encountered this when I upgraded Glide. I got an error regarding a duplicate CoordinatorLayout. I solved that by using com.android.support:design:27.1.0, but then I got another error regarding LiveData$LifecycleBoundObserver.
After a few hours, I gave up and upgraded targetSdkVersion and compileSdkVersion to API 28, as well as using
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
because YOLO. By dumb luck, it worked.
Just gotta upgrade. For me I had to upgrade the following in App build.gradle file:
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.0'
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
Then you will sync your files. When you run you will get a new issue of installation failed pop up boxes. Just cancel those and do the following:
1) Build -> Clean Project
2) Build -> Build Bundle(s) / APK(s) -> Build APK(s)
3) Run your project! Should work!
Follow this link if you want any other details on how I solved it but this should do the trick!

Categories

Resources