[英]app crash when add google login firebaseui
當我們添加此行new AuthUI.IdpConfig.GoogleBuilder().build()
,應用程序崩潰並顯示此錯誤“檢查您的google-services插件配置,未填充default_web_client_id字符串”
該怎么辦? 我已經嘗試了GitHub和StackOverflow中建議的幾乎所有解決方案,但是我的問題沒有解決。 我的項目使用的是Google登錄Firebase UI,但我不知道為什么現在無法使用。
如果我刪除googlebuilder,則該應用程序可以正常運行。
implementation 'com.firebaseui:firebase-ui-auth:4.3.2'
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'io.fabric.tools:gradle:1.25.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files // in the individual module build.gradle files
// classpath 'com.google.gms:google-services:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:4.2.0'
classpath 'com.google.firebase:firebase-plugins:1.1.5'
}
我認為這是Firebase控制台中的問題。 我使用兩個不同的firebase項目來分隔開發和生產環境,並且今天開始在生產中出現此錯誤。
我比較了兩個生成的google-services.json
文件,發現我今天生成的一個文件在oauth_client
數組中缺少另一個對象
這有效-生成default_web_client_id
:
"oauth_client": [
{
"client_id": "blabalbal-blablabal",
"client_type": 1,
"android_info": {
"package_name": "haha",
"certificate_hash": "ahaha"
}
},
{
"client_id": "hahah",
"client_type": 3
}
],
我今天生成了這個,而這個不是生成的default_web_client_id
"oauth_client": [
{
"client_id": "bababab",
"client_type": 1,
"android_info": {
"package_name": "babab",
"certificate_hash": "blablbalb"
}
}
],
因此,有效的對象具有以下額外對象:
{
"client_id": "hahah",
"client_type": 3
}
client_id
在Google雲控制台中的位置-> API和服務 -> 憑據 -> OAuth 2.0客戶端ID- >“ Web客戶端(由Google Service自動創建)”
因此,我將該對象粘貼回作為臨時解決方案...
對我有用的方法如下:
返回Android Studio,在res-> values-> Strings.xml中,創建表單的條目
<string name="default_web_client_id" translatable="false">XXXXXXX</string>
(其中XXXXXXX是您在第3步中從控制台復制的客戶端ID
而不是手動編輯google-services.json
:
Client ID for Web application
的新Client ID for Web application
端ID 。 重要的是您選擇Web應用程序而不是Android。 SHA-1
證書指紋上載到Firebase設置。 google-services.json
。 google-services.json
替換為新的。 OAuth 2.0
中自動生成一個新的Android client
,其中包括您手動創建的Client ID for Web application
的Client ID for Web application
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.