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();
}
});
Looking at the official common status code from google API, the Error 10 = DEVELOPER_ERROR. Then you might be want to check your android manifest but the manifest is fine. So you have to check the clientId on your google console.
A problem with the hardware device itself might be causing the Code 10 error, in which case replacing the hardware is your next logical step. Another possibility, while not very likely, is that the device is not compatible with your version of Windows.
I have also been getting the same error response for the past few days; I have been trying to fixed the problem but no breakthrough and I learnt that the response code (10) means it is a developer problem. I hope someone can profer a solution here.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With