Android FirebaseUI 登录时出现 Google 发布密钥错误 [英] Android FirebaseUI sign in with Google error for release key

查看:22
本文介绍了Android FirebaseUI 登录时出现 Google 发布密钥错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了

从关键工具获取签名以供发布时,我得到:

在 Google Play 商店中,我的上传证书显示为:

在 Google Play 商店中,应用签名证书显示为:

我的上传密钥的 OAuth 2 客户端显示为:

我的 google-services.json 内容是:

<代码>{项目信息":{项目编号":*******",firebase_url":**********",project_id":************",storage_bucket":************"},客户":[{客户端信息":{mobilesdk_app_id":1:77*******:android:*******1e7",android_client_info":{package_name":com.f***********.app"}},oauth_client":[{client_id":77************-2u********************.googleusercontent.com",客户端类型":1,android_info":{package_name":com.f***********.app","certificate_hash":"ea#################################68}},{client_id":7****************-do****************.googleusercontent.com",客户端类型":1,android_info":{package_name":com.f***********.app","certificate_hash":"3e#################################a7}},{client_id":7**************-k8**************.googleusercontent.com",客户端类型":1,android_info":{package_name":com.f***********.app","certificate_hash":"d0#################################66}},{client_id":7**************-sf**************.googleusercontent.com",客户端类型":3}],api_key":[{current_key":AI**************_GQ"}],服务":{appinvite_service":{other_platform_oauth_client":[{client_id":7**************-sf**************.googleusercontent.com",客户端类型":3},{client_id":7*********-3**************.googleusercontent.com",客户端类型":2,ios_info":{bundle_id":com.f***********.app",app_store_id":********"}}]}}}],configuration_version":1";}

如果您有下一步的想法,我们将不胜感激.

解决方案

所以...事实证明,可能需要 4 (四个) 签名密钥...第四个是通过 Google Play 进行内部应用共享(我正在使用).要找到此密钥,您需要导航到 Google Play 控制台,如下所示:

将该密钥添加到您的 Firebase 控制台设置,将新的 google-services.json 下载到您的项目中并运行.

I'm getting the the Developer (Code:10, message:10:) error when trying to sign in using Google Sign-in while using FirebaseUI's Authentication. All works well on development, but when I sign my bundle using my upload key and then run it on a device, it fails.

I looked at associated questions here, here and here and the answers didn't help. As you'll see below, I've tried their recommendations.

What I've tried:

  • Add SHA1 fingerprints to the Project Settings at the Firebase Console for debug, release (upload), and Google Play keys.
  • At console.developers.google.com, created OAuth clients for Android for each of the 3 keys.
  • Still at console.developers.google.com created a new Web client which I then took the Client ID and secret and put it under Firebase's authentication / Google sign in method's Web SDK configuration.
  • Tried all the steps here, here, here, and here
  • Double-checked that my build is actually signed by the correct key (the upload/deploy key)
  • Made sure my google-services.json is the latest with all fingerprints present

My app-level build.gradle file contains the following:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services'

android {

  signingConfigs {
    release {
      storeFile file('myKeystore')
      storePassword 'myPassword'
      keyAlias 'upload'
      keyPassword 'myPassword'
    }
  }
  compileSdkVersion 29

  defaultConfig {
    applicationId "com.######.app"
    minSdkVersion 28
    targetSdkVersion 29
    versionCode 24
    versionName "Test version 1"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

    javaCompileOptions {
      annotationProcessorOptions {
        arguments = ["room.schemaLocation":
          "$projectDir/schemas".toString()
        ]
      }
    }
  }

  buildTypes {

    release {
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
      signingConfig signingConfigs.release
    }

    debug {
      debuggable true
      signingConfig signingConfigs.debug
    }
  }

  packagingOptions {
    exclude 'META-INF/atomicfu.kotlin_module'
  }
  sourceSets {
    main {
      res {
        srcDirs 'src/main/res', 'src/main/res_birds'
      }
    }
  }
}

dependencies {
    // Jar libs
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    // Kotlin
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

    // Support libs
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.recyclerview:recyclerview:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.1.0'

    // Supernova UI Toolkit
    implementation 'io.supernova:android-ui-toolkit:1.2.0'

    // Play Services
    implementation 'com.google.android.gms:play-services-maps:17.0.0'
    implementation 'com.google.android.gms:play-services-auth:18.0.0'

    // Page Control
    implementation 'com.romandanylyk:pageindicatorview:1.0.0'

    // Unit tests dependencies
    implementation 'com.google.firebase:firebase-auth:19.3.1'
    testImplementation 'junit:junit:4.13'

    // Integration tests dependencies
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    // Room components
    implementation "androidx.room:room-runtime:$rootProject.roomVersion"
    kapt "androidx.room:room-compiler:$rootProject.roomVersion"
    androidTestImplementation "androidx.room:room-testing:$rootProject.roomVersion"

    // optional - Kotlin Extensions and Coroutines support for Room
    implementation "androidx.room:room-ktx:$rootProject.roomVersion"

    // Lifecycle components
    kapt "androidx.lifecycle:lifecycle-compiler:$rootProject.archLifecycleVersion"
    implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.archLifecycleVersion"

    // Kotlin components
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    api "org.jetbrains.kotlinx:kotlinx-coroutines-core:$rootProject.coroutines"
    api "org.jetbrains.kotlinx:kotlinx-coroutines-android:$rootProject.coroutines"

    // Material design
    implementation "com.google.android.material:material:$rootProject.materialVersion"

    // Testing
    testImplementation 'junit:junit:4.13'
    androidTestImplementation "androidx.arch.core:core-testing:$rootProject.coreTestingVersion"

    // Navigation
    implementation 'androidx.navigation:navigation-fragment-ktx:2.2.2'
    implementation 'androidx.navigation:navigation-ui-ktx:2.2.2'

    // Stfalcon ImageViewer
    implementation 'com.github.stfalcon:stfalcon-imageviewer:1.0.1'

    // [START gradle_firebase_ui_auth]
    implementation "com.firebaseui:firebase-ui-auth:6.2.1"

    //Firebase
    implementation 'com.google.firebase:firebase-analytics:17.4.3'
    implementation 'com.google.firebase:firebase-core:17.4.3'
    implementation 'com.google.firebase:firebase-firestore-ktx:21.4.3'
    implementation "com.google.firebase:firebase-auth-ktx:19.3.1"


    // Required only if Facebook login support is required
    implementation 'com.facebook.android:facebook-android-sdk:7.0.0'
    // [END gradle_firebase_ui_auth]

}

An extract from a log generated by a Firebase Test Lab device:

06-21 12:11:29.915: E/AuthUI(14514): A sign-in error occurred.
06-21 12:11:29.915: E/AuthUI(14514): com.firebase.ui.auth.FirebaseUiException: Code: 10, message: 10: 
06-21 12:11:29.915: E/AuthUI(14514):    at com.firebase.ui.auth.data.remote.GoogleSignInHandler.onActivityResult(GoogleSignInHandler.java:112)
06-21 12:11:29.915: E/AuthUI(14514):    at com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity.onActivityResult(AuthMethodPickerActivity.java:361)
06-21 12:11:29.915: E/AuthUI(14514):    at android.app.Activity.dispatchActivityResult(Activity.java:7462)
06-21 12:11:29.915: E/AuthUI(14514):    at android.app.ActivityThread.deliverResults(ActivityThread.java:4391)
06-21 12:11:29.915: E/AuthUI(14514):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:4440)
06-21 12:11:29.915: E/AuthUI(14514):    at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49)
06-21 12:11:29.915: E/AuthUI(14514):    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
06-21 12:11:29.915: E/AuthUI(14514):    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
06-21 12:11:29.915: E/AuthUI(14514):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1816)
06-21 12:11:29.915: E/AuthUI(14514):    at android.os.Handler.dispatchMessage(Handler.java:106)
06-21 12:11:29.915: E/AuthUI(14514):    at android.os.Looper.loop(Looper.java:193)
06-21 12:11:29.915: E/AuthUI(14514):    at android.app.ActivityThread.main(ActivityThread.java:6718)
06-21 12:11:29.915: E/AuthUI(14514):    at java.lang.reflect.Method.invoke(Native Method)
06-21 12:11:29.915: E/AuthUI(14514):    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
06-21 12:11:29.915: E/AuthUI(14514):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
06-21 12:11:29.916: D/LifecycleMonitor(14514): Lifecycle status change: com.firebase.ui.auth.KickoffActivity@f99b9c3 in: RESUMED
06-21 12:11:29.940: I/GoogleInputMethod(1463): onFinishInput() : Dummy InputConnection bound
06-21 12:11:29.940: I/GoogleInputMethod(1463): onStartInput() : Dummy InputConnection bound
06-21 12:11:29.945: I/Icing(10330): Indexing done com.google.android.inputmethod.latin-internal.3p:StickerPack [CONTEXT service_id=21 ]
06-21 12:11:29.946: I/Icing(10330): Indexing com.google.android.inputmethod.latin-internal.3p:Sticker from com.google.android.inputmethod.latin [CONTEXT service_id=21 ]
06-21 12:11:29.948: D/LifecycleMonitor(14514): Lifecycle status change: com.firebase.ui.auth.KickoffActivity@f99b9c3 in: PAUSED
06-21 12:11:29.962: I/FirebaseUIActivity(14514): Request Code: 123, Result Code: 0
06-21 12:11:29.962: E/FirebaseUIActivity(14514): Sign in failed with response error code: 4, and message: Code: 10, message: 10: 

In the screenshot below are my SHA-1 fingerprints on the Firebase console. They are defined as:

  • Ending with A7 : Debug
  • Ending with 68 : Release (apk)
  • Ending with 66 : Store (Play Store)

When getting the signatures from key tool for release, I get:

On Google play store, my upload certificate is shown as:

On Google play store, the app signing certificate is shown as:

My OAuth 2 client for my upload key is shown as:

My google-services.json contents are:

{
  "project_info": {
    "project_number": "*******",
    "firebase_url": "**********",
    "project_id": "************",
    "storage_bucket": "************"
  },
  "client": [
    {
      "client_info": {
        "mobilesdk_app_id": "1:77*******:android:*******1e7",
        "android_client_info": {
          "package_name": "com.f***********.app"
        }
      },
      "oauth_client": [
        {
          "client_id": "77************-2u******************.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "com.f***********.app",
            "certificate_hash": "ea#####################################68"
          }
        },
        {
          "client_id": "7****************-do**************.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "com.f***********.app",
            "certificate_hash": "3e#####################################a7"
          }
        },
        {
          "client_id": "7**************-k8**************.googleusercontent.com",
          "client_type": 1,
          "android_info": {
            "package_name": "com.f***********.app",
            "certificate_hash": "d0#####################################66"
          }
        },
        {
          "client_id": "7**************-sf**************.googleusercontent.com",
          "client_type": 3
        }
      ],
      "api_key": [
        {
          "current_key": "AI**************_GQ"
        }
      ],
      "services": {
        "appinvite_service": {
          "other_platform_oauth_client": [
            {
              "client_id": "7**************-sf**************.googleusercontent.com",
              "client_type": 3
            },
            {
              "client_id": "7*********-3**************.googleusercontent.com",
              "client_type": 2,
              "ios_info": {
                "bundle_id": "com.f***********.app",
                "app_store_id": "********"
              }
            }
          ]
        }
      }
    }
  ],
  "configuration_version": "1"
}

Any ideas where to look next will be appreciated.

解决方案

So... It turns out that there are 4 (FOUR) signing keys that might be needed... The fourth one is for internal app sharing (which I was using) via Google Play. To find this key, you need to navigate to Google Play console as shown below:

Add that key to your Firebase console settings, download the new google-services.json into your project and run.

这篇关于Android FirebaseUI 登录时出现 Google 发布密钥错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆