3

Firebase used to work just fine yesterday, but I opened my project this morning just to find that the FirebaseAuth class now has no reference whatsoever to the FirebaseUser class. I cannot find the getCurrentUser() method.

The Google doc still shows that it exists in the class, though!

method removed?!

My imports in that class:

import com.google.firebase.auth.AuthCredential;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.auth.GetTokenResult;
import com.google.firebase.auth.GoogleAuthProvider;

The build.gradle:

api 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.google.firebase:firebase-admin:6.3.0'

And yes:

  • I have apply plugin: 'com.google.gms.google-services' in my build.gradle
  • My app's build.gradle has repositories { google() jcenter() } in it
  • I have Clean my project without getting errors
  • I have restarted AndroidStudio

Current errors in my app (seem to have appeared out of nowhere since yesterday):

  • The getCurrentUser() method doesn't exist anymore in my FirebaseAuth class (which is imported). Same for its signInWithCredential(...), signOut(), createUserWithEmailAndPassword(...) and signInWithEmailAndPassword(...) methods.
  • The isEmailVerified() method doesn't exist anymore in my FirebaseUser class anymore
  • When trying to Make Project, I get this error: Annotation processors must be explicitly declared now. The following dependencies on the compile classpath are found to contain annotation processor. Please add them to the annotationProcessor configuration. - auto-value-1.4.jar (com.google.auto.value:auto-value:1.4) Alternatively, set android.defaultConfig.javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true to continue with previous behavior. Note that this option is deprecated and will be removed in the future. See https://developer.android.com/r/tools/annotation-processor-error-message.html for more details..
  • build.gradle's implementation 'com.android.support:appcompat-v7:27.1.1' is now highlighted as an error (All com.android.support librairies must have the same version specification)

My full build.gradle :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.example.payne.simpletestapp"
        minSdkVersion 16
        targetSdkVersion 27
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    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:27.1.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.2'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:support-vector-drawable:27.1.1'
    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'

    api 'com.google.firebase:firebase-auth:16.0.2'
    implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
    implementation 'com.google.firebase:firebase-core:16.0.1'
    implementation 'com.google.android.gms:play-services-auth:15.0.1'
    implementation 'com.google.firebase:firebase-admin:6.3.0'

    implementation 'org.osmdroid:osmdroid-android:6.0.1'
    implementation 'org.osmdroid:osmdroid-wms:6.0.1'
    implementation 'org.osmdroid:osmdroid-mapsforge:6.0.1'
    implementation 'org.osmdroid:osmdroid-geopackage:6.0.1'
    api 'com.github.MKergall:osmbonuspack:6.5.1'


    implementation 'org.springframework.android:spring-android-rest-template:2.0.0.M3'
    api 'org.apache.httpcomponents:httpclient-android:4.3.5'

    implementation 'com.squareup.picasso:picasso:2.71828'

    // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.6'


}

repositories {
    maven {
        url 'https://repo.spring.io/libs-milestone'
    }
}

apply plugin: 'com.google.gms.google-services'

Please help? I've spent days building this class and now it doesn't work.

payne
  • 4,691
  • 8
  • 37
  • 85
  • 3
    Note that `firebase-admin` is intended to be used in a server, not an Android app. See https://stackoverflow.com/a/42103063/4815718 – Bob Snyder Jul 19 '18 at 21:02
  • **Removing `firebase-admin` from the `build.gradle` and pressing `Sync now` solved the issue**! Weird: I've even put it back in there just to test it out and the project was fine. (I've since then removed it again. I had been wondering if that was only required on the server-side.) While you're here, would you mind me asking: am I supposed to put my `firebase-adminsdk.json` and `google_services.json` in my server's Java project? And which `keys/secrets` will my server need in order to decrypt/verify the third part of the `idToken JWT` ? Thank you !! – payne Jul 19 '18 at 21:25
  • I don't have the experience to help with the other issues. Best to ask a new question. – Bob Snyder Jul 19 '18 at 21:33
  • I [already have](https://stackoverflow.com/questions/51413567/confusion-on-how-to-use-idtoken-properly), and you actually answered one of my listed questions in there, hence me taking a chance on you right here. Thanks anyways. :) – payne Jul 19 '18 at 21:39

4 Answers4

5

Removing firebase-admin from the build.gradle and pressing Sync now solved the issue!

Thanks to BobSnyder (in the comments).

payne
  • 4,691
  • 8
  • 37
  • 85
1

Go to File -> Invalidate caches and restart menu.

sunil
  • 6,444
  • 1
  • 32
  • 44
TomH
  • 2,581
  • 1
  • 15
  • 30
0

The method still exists. Android Studio probably got confused, maybe because something in your project .idea folder got corrupted.

Try quitting Android Studio, deleting the .idea folder at the root of your project, then import the project into Android Studio again.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
-1

The method exist with a little modification.

Try using it FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();