Quy Ba Pham
Quy Ba Pham

Reputation: 91

Meteor.loginWithGoogle error 10 on android

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();
  }
});

Upvotes: 7

Views: 461

Answers (1)

Marvin Klar
Marvin Klar

Reputation: 1917

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

Upvotes: 4

Related Questions