Firebase authentication and database linking - android

In android studio 3.1.3, for linking firebase auth "implementation 'com.google.firebase:firebase-auth:11.6.0'" and
for linking firebase database "implementation 'com.google.firebase:firebase-database:11.8.0'" are the default dependencies provided in app level gradle.
classpath 'com.google.gms:google-services:3.0.0' is the dependency added
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.project.arsalan.adda"
minSdkVersion 21
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'
}
}
}
repositories {
maven {
url "https://maven.google.com/"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
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.2'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.google.firebase:firebase-core:9.8.0'
implementation 'com.google.firebase:firebase-auth:9.8.0'
implementation 'com.google.firebase:firebase-database:9.8.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.android.support:cardview-v7:27.1.1'
implementation 'de.hdodenhof:circleimageview:2.1.0'
implementation 'com.yarolegovich:lovely-dialog:1.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:percent:25.0.1'
}
apply plugin: 'com.google.gms.google-services'
in project level gradle.
I'm usung gradle 3.1.2
The different levels of firebase are causing me errors. Please provide a common level of firebase version that can be used with my gradle build.

just update them with
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
and your google gms update with
dependencies {
classpath 'com.google.gms:google-services:4.0.1'
// ...
}

Here is a link to see the latest Firebase SDK versions. I think it is a reasonable assumption to make that the latest ones will work together.
https://firebase.google.com/support/release-notes/android

I dunno if this problem's unique to Linux.. but anyway finally I had to downgrade the dependencies to get them working..
Module app (dependencies)
compile 'com.google.firebase:firebase-core:9.8.0'
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
Project
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.0.1'

Related

Problem with the Gradle files. I have already connected the project to Firebase and now I am trying to add Google map

My project is connected to Firebase (Database) and now I am tring to add Google map. When I add one of the dependencies I get an error message while the sync.
It says something about using different version etc.
HELP !!
Description:
After I added this line to the app gradle file:
implementation 'com.google.android.gms:play-services-maps:16.0.0'
I got this error:
The library com.google.android.gms:play-services-base is being requested by various other libraries at [[15.0.1,15.0.1]], but resolves to 16.0.1. Disable the plugin and check your dependencies tree using ./gradlew :app:dependencies.
with out the line that I have added everything is fine.
app gradle code:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.rotem.bepart_appproject"
minSdkVersion 23
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(include: ['*.jar'], dir: 'libs')
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-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
**implementation 'com.google.android.gms:play-services-maps:16.0.0'**
}
my project gradle file:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
To solve this, please change the following lines of code:
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.1'
**implementation 'com.google.android.gms:play-services-maps:16.0.0'**
to
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-database:16.0.5'
implementation 'com.google.firebase:firebase-storage:16.0.5'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.android.gms:play-services-maps:16.0.0'
Keeping the same version for all Firebase dependencies is now anti-pattern.

Failed to resolve: com.android.support:support-v4:28.0.0-rc01

I keeping getting these issues once I synced my gradle file. My gradle file looks like this.
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.calcounter.whattappclone"
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 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support:design:28.0.0-rc02'
implementation 'com.andriod.support:support-v4:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
// FirebaseUI for Firebase Realtime Database
implementation 'com.firebaseui:firebase-ui-database:3.2.2'
implementation 'com.andriod.support:support-v4:27.0.0-rc01'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
implementation 'com.squareup.picasso:picasso:2.71828'
testImplementation 'junit:junit:4.12'
//implementation 'com.android.support:support-annotations:27.1.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
**here is my gradle.project file that i have been using, still errors occur, i have tried changing the dependencies but still same error occurs
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
Any solutions this? please
Use the same version and the latest stable version for:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.andriod.support:support-v4:28.0.0'
And remove the duplicate (support-v4) one. Update your gradle in your root build.gradle too:
classpath 'com.android.tools.build:gradle:3.2.1'
I had a similar problem. It turned out that I had 'Offline work' ticked in settings and this was stopping Android studio going to the internet for dependencies. I did not have the required dependencies on local repo so 'Unable to resolve..' kept happening.
Turning it off solved problem.
This is pretty obvious when I thought about it but it caught me out.

play-services-measurement-based requested with several versions

Error:Failed to notify dependency resolution listener.
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.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.intraday.geeks"
minSdkVersion 21
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
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:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
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.android.support:design:26.1.0'
implementation 'com.google.firebase:firebase-core:15.0.4'
implementation 'com.google.android.gms:play-services-location:15.0.4'
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.0'
implementation 'com.firebaseui:firebase-ui:0.6.2'
}
apply plugin: 'com.google.gms.google-services'
Do you have the classpath 'com.google.gms:google-services:4.0.1'?
It is 4.0.1! I updated it from 4.0.0 to 4.0.1 and it is ok!
If it still doesn't work, you can do this, manually add and not use the plugin
There are several problems in your gradle, in general, the issue here is there is an incompatibility. With the latest Google Service version, Firebase an other Google libraries can be used in diferent version with no problem.
Upgrade your gradle: In the Project gradle, upgrade the gradle version
classpath 'com.android.tools.build:gradle:3.1.3'
You will have to updgrade gradle-wrapper.properties file as well
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Add in the project gradle the latest Google Services Version:
classpath 'com.google.gms:google-services:4.0.1'
Compile is no longer supported, so change it to implementation
implementation 'com.android.support:design:26.1.0'
Firebase-ui is no longer meant to be added all at once, remove it:
implementation 'com.firebaseui:firebase-ui:0.6.2' (delete that line)
Follow Firebase-ui docs to add the dependency you actually need

Google Maps and Firebase android plugins dependency collision

I am working on android applications where I am working on Google maps and Firebase. I am putting latest links in my gradle file but it is giving me an error with a red line on GoogleMaps gradle link.
Error:
all gms/firebase libraries must use the exact same version specification (mixinb versions can lead to runtime crahes). Found versions 16.0.0, 15.0.4, 15.0.1. Examples include com.google.firbase:firebase-analytics:16.0.0 and com.google.android.gms:play-services-measurement-base:15.0.4
Gradle:
dependencies{
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.firebase:firebase-core:16.0.0'
}
classpath 'com.google.gms:google-services:4.0.0'
apply plugin: 'com.google.gms.google-services'
Make your play service dependency version equal and try like bellow
dependencies{
compile 'com.google.android.gms:play-services-maps:16.0.0'
compile 'com.google.android.gms:play-services-location:16.0.0'
compile 'com.google.firebase:firebase-core:16.0.0'
}
classpath 'com.google.gms:google-services:4.0.0'
apply plugin: 'com.google.gms.google-services'
There are two more dependencies that need to be added. All the dependencies that I wrote are mentioned below.
compile 'com.google.android.gms:play-services-maps:15.0.1'
compile 'com.google.android.gms:play-services-location:15.0.1'
compile 'com.google.firebase:firebase-core:15.0.1'
compile 'com.google.firebase:firebase-analytics:15.0.1'
compile ' com.google.android.gms:play-services-measurement-base:15.0.4'
I got a perfect combination with Android SDK API 28
No error of any sort in gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.myapp.app"
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 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.android.support:support-v4:28.0.0-rc01'
implementation 'com.android.support:design:28.0.0-rc01'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.github.medyo:android-about-page:1.2.4'
implementation 'com.google.firebase:firebase-messaging:11.8.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'
}
apply plugin: 'com.google.gms.google-services'

Dependency collision between play-services-map and firebase

Im trying to add firebase to a project that i already started, But in the build.gradle (app) i am having a dependency collision between play-services-maps and firebase, i looked everywhere and tried changing the version number but still not working.
here is the build.gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.android.tencho.test"
minSdkVersion 22
targetSdkVersion 26
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:26.1.0'
implementation 'com.google.android.gms:play-services:15.0.1'
// implementation 'com.google.android.gms:play-services-maps:15.0.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.android.support:design:26.1.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.google.code.gson:gson:2.2.+'
compile 'com.google.firebase:firebase-core:16.0.0'
// //Firebase Auth
implementation 'com.google.firebase:firebase-auth:16.0.1'
// //FirebaseUI Auth
compile 'com.firebaseui:firebase-ui-auth:3.3.0'
}
apply plugin: 'com.google.gms.google-services'
Build.gradle (project level)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// The google-services plugin has 2 main functions:
// 1) Process the google-services.json file and produce Android resources that can be used in your
// application's code
// 2) Add dependencies for basic libraries required for the services you have enabled. This step requires
// that the apply plugin: 'com.google.gms.google-services' line be at the bottom of your app/build.gradle file
// so that no dependency collisions are introduced.
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You are using inconsistent version.
Let me tell you simple example.
If you are using google play services 11.8.0, then firebase should also be in same version..
compile 'com.google.android.gms:play-services:11.8.0'
compile 'com.google.firebase:firebase-messaging:11.8.0'
compile 'com.google.android.gms:play-services-maps:11.8.0'
compile 'com.google.firebase:firebase-crash:11.8.0'
compile 'com.google.firebase:firebase-core:11.8.0'
So the main thing to be noted is, you are using inconsistent versions.

Categories

Resources