FirebaseUser class not downloading / importing

2.8k Views Asked by At

I have an Android project linked to Firebase where I am trying to follow the Firebase tutorial to setup Firebase Authentication using the firebase.auth package.

The problem

I need a FirebaseUser variable. But when I try to import using the following import, Android Studio just highlights the FirebaseUser part red. When I hover my mouse over it, it says it cannot resolve it. Of course, when I try to declare it inside a class, it goes red.

import com.google.firebase.auth.FirebaseUser;

Trying to figure out what is wrong

On my app level build.gradle file, I have the following dependencies:

compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.firebaseui:firebase-ui-database:0.4.0'
compile 'com.google.firebase:firebase-auth:9.4.0'

So I did import the firebase-auth package.

Next, when I check out the gradle external libraries, I have the FirebaseAuth class imported under the classes.jar/com.google/android.gms.internal/firebase.auth path and a bunch of other classes. However, I don't see a FirebaseUser class being imported by gradle.

Question: what am I doing wrong?

Some of my hypotheses are:

  1. Wrong import statement in build.gradle - perhaps wrong version number
  2. Gradle is not importing dependencies of dependencies for some reason.

Last note, I have not made any edits on the Manifest file.

2

There are 2 best solutions below

0
On BEST ANSWER

You must use the same version of all Firebase libraries. You can upgrade firebase-auth to 9.8.0 or downgrade firebase-database to 9.4.0.

You must also use the matching version of firebase-ui-database as defined in the table provided in the Firebase UI docs. The docs also explain that the UI libs have transitive dependencies on other Firebase libs. In your case, you can eliminate firebase-database from the list.

Example:

compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
//compile 'com.google.firebase:firebase-database:9.8.0'
compile 'com.android.support:recyclerview-v7:24.2.1'
compile 'com.firebaseui:firebase-ui-database:1.0.0'
compile 'com.google.firebase:firebase-auth:9.8.0'
0
On

Use the latest dependencies. Replace your versions with 11.6.2 of google services and firebase-ui-database:1.0.2 if your compiled version is 26 or later.