Meteor.loginWithGoogle error 10 on android

放肆的年华 提交于 2019-12-14 04:17:20

问题


I used the function Meteor.loginWithGoogle as below to login with google. It's working on browser but It's fail (the console log is error 10) when I build to apk (by cordova).

handleLoginError(err, service) {
   console.error(err);
}

Meteor.loginWithGoogle({}, (err) => {
  if (err) {
    this.handleLoginError(err, 'google');
  } else {
    this.handleLoginSuccess();
  }
});

回答1:


Just found the solution on https://forum.ionicframework.com/t/google-login-error-10/93230/4

In your case, Cordova is not signing your APK correctly. This is why the error only occurs in the apk. You can solve this by creating a valid keystore, which Cordova can use to sign the apk.


Option 1

You can create the keystore using e.g. this command: keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 Make sure to edit it to your needs. If you want to know more about this command, you can read this answer.

Next, you neew to get the SHA1 from the key you just generated using this command: keytool -exportcert -list -v -alias androiddebugkey -keystore ~/.android/debug.keystore

You can use this SHA1 to get your token, IDs and keys from https://developers.google.com/mobile/add?platform=android&cntapi=signin

Use the command meteor build android --release to build your app and to generate an apk file.

Finally you can use the command jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore HelloWorld-release-unsigned.apk alias_name to jar sign the generated apk file with the keystore.


Option 2

Alternatively you can create a signing properties file platforms/android/debug-signing.properties containing your keystore file, password as shown below. Example:

keyAlias=yourkeyAlias
keyPassword=yourkeyPassword
storeFile=theFileContainingTheKeystore
storePassword=yourStorePassword

You can get more information about this in the publishing documentation: https://ionicframework.com/docs/v1/guide/publishing.html



来源:https://stackoverflow.com/questions/45854992/meteor-loginwithgoogle-error-10-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!