简体   繁体   English

谷歌登录不适用于使用电容器生成的离子 android 移动应用程序 - 抛出异常为 10

[英]google sign in does not work on ionic android mobile application generated using capacitor - exception thrown as 10

I am developing an ionic app for android and generating it using capacitor.我正在为 android 开发离子应用程序并使用电容器生成它。 I want to introduce google login to my app.我想将谷歌登录引入我的应用程序。 I am getting err 10 when I try to login.尝试登录时出现错误 10。 Created a client id for android for the keys tore being used to sign the app.为 android 创建了一个客户端 ID,用于为用于签署应用程序的密钥撕裂。 The code is as below代码如下

import '@codetrix-studio/capacitor-google-auth';
import { AngularFireAuth } from '@angular/fire/auth';
import { AngularFirestore } from '@angular/fire/firestore';
import { Router } from '@angular/router';
import { Subject, ReplaySubject } from 'rxjs';
import { GooglePlus } from '@ionic-native/google-plus/ngx';
import * as firebase from 'firebase';
import { Plugins } from '@capacitor/core';
import { FirebaseApp } from '@angular/fire';
import { Platform } from '@ionic/angular';

signInWithGoogle(): Promise<void> {

        return new Promise((resolve, reject) => {

            this.TESTSubject.next('calling google.login');
            this.google.login({
                webClientId: '<my-client-id-part-from-oogle-developer-dashboard>.apps.googleusercontent.com',
                offline: true, scopes: 'profile email'
            })
            .then(gplusUser => {
                this.TESTSubject.next('gplus user recieved =' + gplusUser.email);
                return this.afa.signInWithCredential(firebase.auth.GoogleAuthProvider.credential(gplusUser.idToken));
            })
            .then(r => {
                this.TESTSubject.next('firebase loin OK ');
                resolve();
            })
            .catch(err => {
                reject(err);
            });
        });

    }

When I use this on the device I get the exception thrown when calling this.google.login(.... The exception comes as 10当我在设备上使用它时,调用this.google.login(....时抛出异常。异常为 10

I use the below command to generate the android app using capacitor in my project directory我使用以下命令在我的项目目录中使用电容器生成 android 应用程序


    ionic build && npx cap sync android && ionic capacitor copy android && cd android && gradlew assembleRelease && cd app/build/outputs/apk/release && jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore online-mkt.keystore app-release-unsigned.apk online-mkt-mobileapps
    
    zipalign -v 4 app-release-unsigned.apk mobruk-signed.apk

I have been struggling on this for days.这几天我一直在为此苦苦挣扎。 Any help is much appreciated.任何帮助深表感谢。

my ionic info gives the below我的离子信息如下


    Ionic:
    
       Ionic CLI                     : 5.4.16 (C:\Users\<myname>\AppData\Roaming\npm\node_modules\ionic)
       Ionic Framework               : @ionic/angular 5.0.7
       @angular-devkit/build-angular : 0.803.26
       @angular-devkit/schematics    : 8.3.26
       @angular/cli                  : 8.3.26
       @ionic/angular-toolkit        : 2.2.0
    
    Capacitor:
    
       Capacitor CLI   : 2.2.1
       @capacitor/core : 2.2.1
    
    Cordova:
    
       Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
       Cordova Platforms : android 8.1.0
       Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 5 other plugins)
    
    Utility:
    
       cordova-res : not installed
       native-run  : not installed
    
    System:
    
       Android SDK Tools : 26.1.1 (C:\Users\<myname>\AppData\Local\Android\Sdk)
       NodeJS            : v10.16.0 (C:\Program Files\nodejs\node.exe)
       npm               : 6.13.1
       OS                : Windows 7

Did you add the sha1 fingerprint from firebase console?您是否从 firebase 控制台添加了 sha1 指纹?

在此处输入图像描述

here how get sha1 from keystore ( SHA-1 fingerprint of keystore certificate )这里如何从密钥库获取 sha1( 密钥库证书的 SHA-1 指纹

her more info about ( https://developers.google.com/android/guides/client-auth )她的更多信息( https://developers.google.com/android/guides/client-auth

I found the issue.我发现了这个问题。 I had my package name specified in configs.xml in my ionic project.我在我的离子项目中的 configs.xml 中指定了我的 package 名称。 But that that was not the one as I expected which was embedded in my apk file.但这不是我预期的嵌入在我的 apk 文件中的那个。 I found it out by running the below command我通过运行以下命令找到了它

aapt dump badging my apk file with path aapt dump 用路径标记我的 apk 文件

The name of the package there was io.ionic.starter So in my google cloud console I deleted the credential for android type and recreated another credential giving the package name as io.ionic.starter. The name of the package there was io.ionic.starter So in my google cloud console I deleted the credential for android type and recreated another credential giving the package name as io.ionic.starter. The exception is no more and it logs in. I am not sure why the package name is not taken from my configs.xml file.异常不再存在,它会登录。我不确定为什么 package 名称不是从我的 configs.xml 文件中获取的。 I am nt using andoid studio to build the app, I am building the app on command prompt with the below command我没有使用 andoid studio 来构建应用程序,我正在使用以下命令在命令提示符下构建应用程序

ionic build && npx cap sync android && ionic capacitor copy android && cd android && gradlew assembleRelease && cd app/build/outputs/apk/release && jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore online-mkt.keystore app-release-unsigned.apk online-mkt-mobileapps ionic build && npx cap sync android && ionic capacitor copy android && cd android && gradlew assembleRelease && cd app/build/outputs/apk/release && jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore online-mkt.keystore app-release- unsigned.apk online-mkt-mobileapps

This might be the reason for the package on configsxml not getting embedded to the apk.这可能是 configsxml 上的 package 没有嵌入到 apk 的原因。 Not sure.没有把握。 Hope some one out there can shed some light.希望有人能提供一些启示。 Thanks Martin for your time for trying to help me out.感谢 Martin 抽出宝贵时间帮助我。 Much appreciated.非常感激。 Thanks谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ionic5 电容器应用程序适用于 android 7、8 的较低版本,但不适用于 android 10 - ionic5 capacitor app works on lower versions of android 7, 8 but does not work on android 10 使用 Ionic Capacitor 的 Android 开发是否仍然不适用于 Java 9? - Does Android Development with Ionic Capacitor still not work with Java 9? Google Login 不适用于 AWS Mobile Hub 生成的 Android 应用程序 - Google Login does not work with AWS Mobile Hub generated Android app 本机文件传输插件不会使用带电容器的 Ionic 在 android 10 和 android 11 中创建目录 - Native file transfer plugin doesn't create directory in android 10 and android 11 using Ionic with capacitor meteor 移动应用程序不适用于 android 9 和 10 - meteor mobile app does not work on android 9 and 10 Google Paly登录无法在Android中使用 - Google Paly sign in Does not work in Android Android味离子电容 - Ionic Capacitor with Android flavor 安卓应用程序中的谷歌登录 - Google Sign IN in android application 如何在 Android 设备/仿真器上 LiveReload 和调试离子/电容器应用程序 - How to LiveReload and debug Ionic/Capacitor application on Android device/emulator 使用 kotlin 构建 android 应用程序时抛出异常“后端(JVM)内部错误:生成错误的字节码” - Exception "Back-end (JVM) Internal error: wrong bytecode generated" is thrown when building android application with kotlin
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM