CapacitorGoogleAuth icon indicating copy to clipboard operation
CapacitorGoogleAuth copied to clipboard

Problem with SignIn in android.

Open sumit26-code opened this issue 4 years ago • 16 comments

Hello everyone! I upgraded by application from capacitor 2 to capacitor 3. Now, I am facing issue with google login.

I am using @codetrix-studio/capacitor-google-auth": "3.0.1" plugin for this. And I am getting the following issue in android, for web its working fine for me.

Screenshot 2021-06-04 at 5 46 56 PM

sumit26-code avatar Jun 04 '21 12:06 sumit26-code

I am having same issue

dotnetdreamer avatar Jun 05 '21 10:06 dotnetdreamer

I was facing same issue. My web was working but not Android. So here is what i did:

Firebase Console: image

dotnetdreamer avatar Jun 05 '21 11:06 dotnetdreamer

Tried all combinations of both android client id and web client id - nothing works

Capactiror v3

fannyfan414 avatar Jun 18 '21 14:06 fannyfan414

Can u make a sample so we can check it out ?

dotnetdreamer avatar Jun 18 '21 15:06 dotnetdreamer

Can u make a sample so we can check it out ?

if you have working solution, please record step by step video or text guide with screens

fannyfan414 avatar Jun 18 '21 16:06 fannyfan414

It was working fine on Capacitor 2 before the upgrade. Now I'm receiving this error for Android. Web is working fine, so I don't assume it's a credential issue (otherwise it would be bugged too?)

Please, help

jonit-dev avatar Jun 20 '21 03:06 jonit-dev

After wasting some hours of my life, I've come up with a solution. It would be great if the plugin docs covered all of this, on the main page.

Probably this is happening due to a SHA1 signature mismatch between your debug app (the one you're trying to run in emulator) and firebase.

To fix it on Android studio 4.2, click on Gradle tab (right side) and type gradle signingReport

This will output in a panel on the bottom left a SHA1 debug key, that you must add to your firebase project settings

Now open Firebase, and add it: image

Then try running your emulator again. It will probably work (I hope).

btw, my MainActivity.java is:


import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth;

public class MainActivity extends BridgeActivity {

     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

        registerPlugin(GoogleAuth.class);
     }

}

jonit-dev avatar Jun 20 '21 03:06 jonit-dev

I was facing same issue. My web was working but not Android. So here is what i did:

  • In addition to creating credentials (OAuth Client ID) for web https://console.cloud.google.com/apis/credentials, i did also for Android
  • Then i went to https://console.firebase.google.com/u/ and created and Android project and downloaded the google-services.json and copied to my android -> app folder.
  • I then ran npx cap sync and run the app and it started working image

Firebase Console: image

It works for me, thanks.

sumit26-code avatar Jul 01 '21 03:07 sumit26-code

The error after the migration from Capacitor 2 to 3 should be now fixed with the newer version.

NLueg avatar Jul 15 '21 04:07 NLueg

According to my error logs in Sentry, about 10% of my users face this error. This is very strange. How it can work on some devices and don't work on others?

cwayfinder avatar Jul 23 '21 06:07 cwayfinder

They've released outdated code for Android in npm. Try to install this plugin from the master branch

gugu avatar Sep 17 '21 13:09 gugu

I also encountered the same mistake, but I did according to the answers of others above, and still reported this mistake

UTSOURCE avatar Sep 30 '21 06:09 UTSOURCE

After wasting some hours of my life, I've come up with a solution. It would be great if the plugin docs covered all of this, on the main page.

Probably this is happening due to a SHA1 signature mismatch between your debug app (the one you're trying to run in emulator) and firebase.

To fix it on Android studio 4.2, click on Gradle tab (right side) and type gradle signingReport

This will output in a panel on the bottom left a SHA1 debug key, that you must add to your firebase project settings

Now open Firebase, and add it: image

Then try running your emulator again. It will probably work (I hope).

btw, my MainActivity.java is:


import android.os.Bundle;
import com.getcapacitor.BridgeActivity;
import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth;

public class MainActivity extends BridgeActivity {

     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

        registerPlugin(GoogleAuth.class);
     }

}

This did fix the issues on the android emulator. But I still have issues with real devices. I added the sha1 from my .keystore but it doesn't work. I have the "somethign went worng" error.

Read1337 avatar Oct 02 '21 10:10 Read1337

Still facing the issue. Everything was working perfectly before Capacitor 3.

I've triple checked every key, and everything is fine.

How can I fix/debug this ?

grallc avatar Oct 12 '21 20:10 grallc

Still facing the issue. Everything was working perfectly before Capacitor 3.

I've triple checked every key, and everything is fine.

How can I fix/debug this ?

Not sure what exactly is your problem, but for me I had to add the SHA-1 key ,from google play, to my firebase project. I had the key from my .keystore but it didn't work.

On our Google Play Console. Go to, Setup->App Integrity, make sure you add this SHA-1 signing key

I spent a lot of time on this, hope it helps.

Read1337 avatar Oct 13 '21 11:10 Read1337

Still facing the issue. Everything was working perfectly before Capacitor 3. I've triple checked every key, and everything is fine. How can I fix/debug this ?

Not sure what exactly is your problem, but for me I had to add the SHA-1 key ,from google play, to my firebase project. I had the key from my .keystore but it didn't work.

On our Google Play Console. Go to, Setup->App Integrity, make sure you add this SHA-1 signing key

I spent a lot of time on this, hope it helps.

Hi, Thanks for the answer. I've tried what you've suggest but it's unfortunately not working neither. Do you see anything wrong on my setup ? All details in #154

Thanks!

grallc avatar Oct 13 '21 15:10 grallc