Crimson1222 Crimson1222 - 11 days ago 5
Android Question

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?

Answer
  • 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!