简体   繁体   中英

Android Firebase Authentication not working

For my Android application, I'm trying to use Firebase to authentication and data storage. Right now, I'm stuck on authentication. When my application loads, an error stacktrace appears in the Android Studio console.

W/GooglePlayServicesUtil: Cannot find Google Play services package name.

android.content.pm.PackageManager$NameNotFoundException: com.google.android.gms

at android.app.ApplicationPackageManager.getPackageInfo(ApplicationPackageManager.java:137)

at com.google.android.gms.internal.zzrt.getPackageInfo(Unknown Source)

at com.google.android.gms.common.zze.zzby(Unknown Source)

at com.google.android.gms.common.zze.zzbx(Unknown Source)

at com.google.android.gms.common.zze.zzbs(Unknown Source)

at com.google.android.gms.common.zze.isGooglePlayServicesAvailable(Unknown Source)

at com.google.android.gms.common.zzc.isGooglePlayServicesAvailable(Unknown Source)

at com.google.android.gms.common.GoogleApiAvailability.isGooglePlayServicesAvailable(Unknown Source)

at com.google.android.gms.internal.zzqh$zzc.connect(Unknown Source)

at com.google.android.gms.internal.zzqh$zzc.zza(Unknown Source)

at com.google.android.gms.internal.zzqh.zza(Unknown Source)

at com.google.android.gms.internal.zzqh.handleMessage(Unknown Source)

at android.os.Handler.dispatchMessage(Handler.java:98)

at android.os.Looper.loop(Looper.java:148)

at android.os.HandlerThread.run(HandlerThread.java:61)

And when I try to submit my email and password credentials, the following messages appear.

07-07 14:19:45.330 7430-7449/com.tech_centric.developmentworkflowfirebase W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.

07-07 14:19:45.330 7430-7449/com.tech_centric.developmentworkflowfirebase W/GooglePlayServicesUtil: Google Play Store is missing.

My project/build.gradle looks like this:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
        classpath 'com.google.gms:google-services:3.0.0'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

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

And my project/app/build.gradle looks like this:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.tech_centric.developmentworkflowfirebase"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
    compile 'com.android.support:design:24.0.0-alpha2'
    compile 'com.google.firebase:firebase-core:9.2.0'
    compile 'com.google.firebase:firebase-auth:9.2.0'
}

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

Is there something that I'm missing to make this work?

  • I am not sure if you have imported the generated google-services.json file in the app/ folder of your project. If you didn't, follow this link : https://firebase.google.com/docs/android/setup in section "Add Firebase to your app".

  • If it still shows you the error, you can try editing the dependencies in the build.gradle file in your app/ folder as following: compile 'com.google.firebase:firebase-core:9.2.0' compile 'com.google.firebase:firebase-auth:9.2.0' to compile 'com.google.firebase:firebase-core:9.0.2' compile 'com.google.firebase:firebase-auth:9.0.2'

Hope it helps!

I found this error when I was running the app using virtual machine Genymotion API 21. The solution for my problem is install (add) google play service into virtual machine Genymotion. The file zip can be download from this link ARM Translation Installer v1.1 and google play service Android version 5.0 . To install google play service just drug and drop both of file zips into home screen Android Genymotion emulator and reboot the emulator by running adb reboot or click power button of Android Genymotion emulator.

Yes you are missing enabling the SIGN-IN-METHOD under Authentication. Here is screenshot, after enabling the method you will not get this error. 在此处输入图片说明

Now try uploading files on storage, now it will work.

在所有项目和构建脚本中添加 google()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM