3

對於我的Android應用程序,我嘗試使用Firebase進行身份驗證和數據存儲。現在,我停留在身份驗證上。當我的應用程序加載時,Android Studio控制檯中會顯示錯誤堆棧跟蹤。Android Firebase身份驗證不起作用

W/GooglePlayServicesUtil:無法找到Google Play服務包名稱。

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

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

在com.google.android .gms.internal.zzrt.getPackageInfo在com.google.android.gms.common.zze(未知來源)

在com.google.android.gms.common.zze.zzby(未知來源)

.zzbx(未知來源)

在com.google.android.gms.common.zze.zzbs(來源不明)

在com.google.android.gms.common.zze.isGooglePlayServicesAvailable(來源不明)

在COM。 google.android.gms.common.zzc.isGooglePlayServicesAvailable(未知來源)

在com.google.android.gms.common.GoogleApiAvailability.isGooglePlayServicesAvailable(未知來源)

在com.google.android.gms。 internal.zzqh $ zzc.connect(未知來源)

在com.google.android.gms.internal.zzqh $ zzc.zza(來源不明)

在com.google.android.gms.internal.zzqh.zza(來源不明)

在com.google.android.gms.internal.zzqh.handleMessage(未知來源)

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

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

at a ndroid.os.HandlerThread.run(HandlerThread.java:61)

而當我嘗試提交我的電子郵件和密碼憑據時,會出現以下消息。

07-07 14:19:45.330 7430-7449/com.tech_centric.developmentworkflowfirebase W/DynamiteModule:用於com.google.firebase.auth本地模塊描述符類未找到。

07-07 14:19:45.330 7430-7449/com.tech_centric.developmentworkflowfirebase W/GooglePlayServicesUtil:Google Play商店缺失。

我的項目/的build.gradle看起來是這樣的:

// 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 
} 

而且我的項目/應用程序/編譯。gradle看起來像這樣:

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' 

有什麼,我失蹤,使這項工作?

+1

您是在模擬器上還是在實際設備上啓動應用程序?目標上是否安裝了谷歌播放服務? – dthulke

+0

@dthulke我正在模擬器上啓動應用程序。如何檢查模擬器上是否安裝了谷歌播放服務? – Crimson1222

+0

@dthulke我安裝了它,但現在它給了我一個新的錯誤。 W/DynamiteModule:未找到com.google.firebase.auth的本地模塊描述符類。 W/GooglePlayServicesUtil:Google Play服務已過時。需要9256000,但找到9080480 – Crimson1222

回答

4
  • 我不知道你是否已經導入生成的谷歌,services.json文件在你的項目的應用程序/文件夾中。如果您沒有,請點擊此鏈接:https://firebase.google.com/docs/android/setup,在「嚮應用添加Firebase」部分。

  • 如果你仍然顯示錯誤,你可以嘗試編輯依賴於的build.gradle文件在您應用程序/文件夾如下:編譯「com.google.firebase :火力芯:9.2.0' 編譯 'com.google.firebase:火力-AUTH:9.2.0'編譯 'com.google.firebase:火力核:9.0.2' 編譯' com.google.firebase:firebase-auth:9.0.2'

希望它有幫助!

+0

是的。我將google-services.json文件放在應用程序/文件夾中。我將嘗試對firebase依賴關係進行分級。 – Crimson1222

+0

降級依賴關係!謝謝! – Crimson1222

0

我在使用虛擬機Genymotion API 21運行應用程序時發現此錯誤。我的問題的解決方案是將Google Play服務安裝(添加)到虛擬機Genymotion中。文件zip可以從此鏈接下載ARM Translation Installer v1.1和谷歌播放服務Android version 5.0。要安裝谷歌播放服務只是藥物,並將兩個文件的zip文件放入主屏幕Android Genymotion模擬器,並通過運行adb reboot或點擊Android Genymotion模擬器的電源按鈕重新啓動模擬器。

0

是的,你缺少啓用身份驗證下的SIGN-IN-METHOD。 這裏是屏幕截圖,啓用該方法後,您將不會收到此錯誤。 enter image description here

現在嘗試上傳文件上的存儲,現在它會工作。

+1

我確實已啓用身份驗證,所以很明顯,這不是您在未啓用身份驗證方法時得到的錯誤。 – Crimson1222