Error in Gradle Build App level when adding firebase UI - android

Error
How can I add Firebase UI dependency? I'm not sure which version is compatible with my sdk version 26.

Take a look at release notes for FirebaseUI i.e. https://github.com/firebase/FirebaseUI-Android/releases
It contains following (for latest version...3.0)
This version has the following notable transitive dependencies:
Firebase / Play services 11.4.2
Support Library 26.1.0
Facebook SDK 4.27
In general you can run something like following to list transitive dependencies that exist in your build.
./gradlew -q dependencies <your_module>:dependencies

Related

Android: build.gradle error when adding firebase requirements

When I follow the firebase instructions and added:
classpath 'com.google.gms:google-services:4.2.0'
to the dependencies and:
implementation 'com.google.firebase:firebase-core:17.0.0'
to the dependencies as well, the all of a sudden I get an error on this line in the dependencies:
implementation 'com.android.support:appcompat-v7:27.1.1'
Here is the error message:
Dependencies using groupId com.android.support and androidx.* can not be combined but found IdeMavenCoordinates{myGroupId='com.android.support', myArtifactId='animated-vector-drawable', myVersion='27.1.1', myPacking='aar', myClassifier='null'} and IdeMavenCoordinates{myGroupId='androidx.lifecycle', myArtifactId='lifecycle-viewmodel', myVersion='2.0.0', myPacking='aar', myClassifier='null'} incompatible dependencies less... (⌘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).
What shall I do? Why this happened after adding firebase?
(EDIT: THIS IS AN IMPROVED ANSWER OF THE ORIGINAL ANSWER WHICH IS GOT DELETED DUE TO CERTAIN ISSUES.)
Firebase migrated to AndroidX in the latest release. Which means that,
AndroidX maps the original support library API packages into the
androidx namespace. Only the package and Maven artifact names changed;
class, method, and field names did not change.
So latest firebase releases no longer supports for the old support libraries. You have to either downgrade firebase with,
implementation 'com.google.firebase:firebase-core:16.0.9'
or migrate your app to use AndroidX as mentioned below.(Anyway if your app depends on any com.google.android.gms or com.google.firebase libraries, you should prepare for this migration)
This release is a MAJOR version update and includes breaking changes.
With this release, libraries are migrated from the Android Support
Libraries to the Jetpack (AndroidX) Libraries. The updated 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.
With Android Studio 3.2 and higher, migration is lot easier. selecting Refactor > Migrate to AndroidX from the menu bar we can migrate to AndroidX.
And any maven dependencies can be handled as on below,
Maven dependencies that have not been migrated to the AndroidX
namespace, the Android Studio build system also migrates those
dependencies for you when you set the following two flags to true in
your gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
To migrate an existing project that does not use any third-party
libraries with dependencies that need converting, you can set the
android.useAndroidX flag to true and the android.enableJetifier flag
to false.

Android Studio cannot find Firebase

I'm trying to get the Android P preview setup, and in the process I am upgrading all my dependencies, but it gets mad when Firebase and Google Play Services don't match versions. (It wont build). The latest version of Google Play Services is 15.0.1 as denoted here. The latest version of Firebase is version 16.0.0, according to this page. So I figured I should use 15.0.1 for all of them. However Android Studio can't seem to resolve any version of Firebase. It always gives me an error like this:
It gives the same error for any version I give it.
Here are my dependencies:
implementation 'com.google.firebase:firebase-core:15.0.1'
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.android.gms:play-services-base:15.0.1'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.android.gms:play-services-location:15.0.1'
implementation 'com.google.android.gms:play-services-places:15.0.1'
Try to update firebase like below:
implementation 'com.google.firebase:firebase-core:16.0.0'
Also make sure that you use latest google service:
classpath 'com.google.gms:google-services:4.0.1'
From docs you are linked to you can find annotation
// Getting a "Could not find" error? Make sure you have
// added the Google maven respository to your root build.gradle
allprojects {
// ...
repositories {
// ...
maven {
url "https://maven.google.com" // Google's Maven repository
}
}
The firebase-core library wasn't released at version 15.0.1. You can see via http://maven.google.com that you should use either 15.0.2 or 16.0.0 (my suggestion is to always use 16+ libraries when they exist b/c we're removing version ranges from the POM files (therefore, you'll go back to hermetic builds). The May 23rd entry of our release notes goes into more details, if needed. (https://developers.google.com/android/guides/releases)
The assumption that all of the libraries should be used at the same version is no longer valid as of versions 15.0.0 and greater. Libraries will continue to release independently and with ever-diverging version numbers (following a SemVer.org scheme).

Firebase libraries with conflicting library versions fail to run my app

So i'm using the following firebase library version in my app:
Project's build.gradle:
firebase_version = '15.0.0'
And the following library dependencies:
App's build.gradle:
implementation "com.google.firebase:firebase-firestore:$firebase_version"
It looks like these versions were released on the 10th of April, however when compiling my app with the updated libraries, it fails to run with the following error:
error: cannot access zzbgl
class file for com.google.android.gms.internal.zzbgl not found
When checking all my library versions, my build.gradle has the following error:
not sure if anyone has experienced this by any chance since the latest updates? Before updating from 12.0.1, everything was working.
Thanks
Simply override (add to your gradle file) the conflicting library, updating the version to match the ones you already have in your gradle file. Somewhere in your dependencies someone is using an older version of this library and it's crashing with your version:
implementation "com.google.android.gms:play-services-auth:$firebase_version"

Google play services version automatically changes to 11.8

Recently i upgraded my project to android studio 3
In my build.gradle , i have: compile "com.google.android.gms:play-services-maps:10.2.1"
So it must use gms 10.2.1 , but in "#integer/google_play_services_version" i have following:
<integer name="google_play_services_version">11910000</integer>
And in the project --> External libraries i can clearly see that it compiles gms version 11.8:
Why this happens?
Use ./gradlew dependencies to check the dependency tree.
You are simply using a library that has a dependency with 11.8.0 and gradle uses the newest version.

Android app getting crashed : com.android.support.constraint:constraint-layout : Error

I have started to learn Android. I am trying to work on Google Map APIs. My app is crashing every time I am trying to launch it, upon investigation I found one notification in build.gradle file.
Please refer this image to see the message from compiler
I changed com.android.support.constraint:constraint-layout:1.0.0-alpha7 to com.android.support.constraint:constraint-layout:1.0.0-alpha9 to support compileSdkVersion 26. I am not finding any relevant links on Google to fix this issue.
Your compile sdk version is greater than your support libraries,
try modifying your gradle as
android {
...
compileSdkVersion 25
...
}
and within the dependency you can add
compile 'com.android.support.constraint:constraint-layout:1.0.2'
Please refer to this post, if you run the Gradle command you can see what of your dependencies has a different buildtools version.
From the post:
Run a Gradle dependency report to see what your full tree of
dependencies is. From there, you will see which one of your libraries
is asking for a different version of the Android Support libraries.
For whatever it is asking for, you can ask for it directly with the
25.2.0 version, or use Gradle's other conflict resolution approaches to arrange to get the same version.
Run:
./gradlew -q dependencies <module-name>:dependencies --configuration compile
Example:
./gradlew -q dependencies app:dependencies --configuration compile

Categories

Resources