Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

E/FirebaseInstanceId: Token retrieval failed: AUTHENTICATION_FAILED Android studio

Ok, going a little crazy here. Eveytime I launch my app in android studio, before any code is handled get this error:

E/FirebaseInstanceId: Token retrieval failed: AUTHENTICATION_FAILED

App Gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "fraternityandroid.greeklife"
        minSdkVersion 22
        targetSdkVersion 27
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.6.2'
implementation 'com.google.firebase:firebase-auth:11.6.2'
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'
    implementation 'com.google.android.gms:play-services:11.6.2' //11.7.43 //could do 11.6.2 all around
}


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

Project Gradle:

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.0'


    // 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.0'
}
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

code:

    public void validateExists() {
    FirebaseDatabase database = FirebaseDatabase.getInstance();
    DatabaseReference myRef = database.getReference("Users");

    myRef.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot snapshot) {
            for (DataSnapshot postSnapshot: snapshot.getChildren()) {
                Map<String, Object> post = (HashMap<String, Object>) postSnapshot.getValue();
                for (Map.Entry<String, Object> entry : post.entrySet()) {
                    if (mEmail.getText().toString().equals(entry.getValue())) {
                        System.out.println("found it!!!");
                        authenticate();
                        return;
                    }
                    System.out.println("Didnt find it!!!");
                }
            }
        }

        @Override
        public void onCancelled(DatabaseError error) {
            System.out.println("Errorrrr it!!!");

            //log error
        }
    });
}

Im just trying to run some damn firebase calls. My play store on the emulator (API 26) is running 11.7.2

Please helpppp Thank you `

like image 673
Jonah Elbaz Avatar asked Dec 19 '17 16:12

Jonah Elbaz


2 Answers

Actually it happend to me when I started using LAN with proxy as soon as i changed to wifi it started to work perfectly .. so i guess it is a communication issue .. but my advice is to use your android phone instead of the emulator.

like image 74
Mustafa Shahoud Avatar answered Oct 09 '22 01:10

Mustafa Shahoud


I added my debug SHA certificate fingerprint to the Firebase project configuration

keytool -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore

The default password is android

like image 38
GianpaMX Avatar answered Oct 09 '22 01:10

GianpaMX