Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android fails (Unable to find a Capacitor plugin to handle requestCode) #147

Open
sbellver opened this issue Sep 13, 2021 · 11 comments
Open

Comments

@sbellver
Copy link

Hi all.

I'm on Capacitor 3 and Vue 2 (quasar framework).

In iOs all works fine.

In android, when I click on the button shows the gmail accounts. Then select the account and notching happens .

I can see in the log:

V/Capacitor/Plugin: To native (Capacitor plugin): callbackId: 115059358, pluginId: GoogleAuth, methodName: signIn
V/Capacitor: callback: 115059358, pluginId: GoogleAuth, methodName: signIn, methodData: {}
D/Capacitor: App paused
D/Capacitor: Unable to find a Capacitor plugin to handle requestCode, trying Cordova plugins 578501389
E/Capacitor/Plugin: Something went wrong
    com.google.android.gms.common.api.ApiException: 10: 
...

It's like the plugin are not present in android target.

But If I run npx cap sync android:

[info] Found 1 Cordova plugin for android:
       onesignal-cordova-plugin@2.11.4
✔ copy android in 301.38ms
✔ Updating Android plugins in 10.24ms
[info] Found 4 Capacitor plugins for android:
       @capacitor-community/facebook-login@3.1.1
       @capacitor/camera@1.0.5
       @capacitor/geolocation@1.1.0
       @codetrix-studio/capacitor-google-auth@3.0.2
⠙ update android [info] Found 1 Cordova plugin for android:
       onesignal-cordova-plugin@2.11.4
✔ update android in 103.05ms

In androidClientId I set the name of de app: domain.name

I set server_client_id as google-services.json and copy this file into android/app/

I register the plugin in MainApplication.java

import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth;

public class MainActivity extends BridgeActivity {
  @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        registerPlugin(com.getcapacitor.community.facebooklogin.FacebookLogin.class);
        registerPlugin(GoogleAuth.class);
    }
}

But doesn't work in android.

@aguirrel
Copy link

Hi guys, I have the same problem. Any update?

@sbellver
Copy link
Author

I'm in the same situation, any change.

I see maybe the error is ApiException: 10 ( #15 ) but have not success after change SHA1 in firebase for production & devel

To get the sha1 for your app, if helps:

keytool -list -v -keystore ~/path/to/myApp.Keystore -alias myAlias

Maybe is not compatible with Capacitor 3 & Android yet?

@aguirrel
Copy link

I think main problem is the SHA1 fingerprint, using keytool didn't work, when I tried to create an Andodroid API from google console it didn't accepted it.

So I solved it doing the following:

1 - https://stackoverflow.com/a/34223470 , option 2: Work with Google Maps Activity

2 - Then go to google console, create a new oath for android and use the SHA1 you got from stackoverflow solution.

3 - After that you shoud go to firebase, create a new project but be carefull there, when ask for project name wait until show all yours google console projects (don't create a new one from scratch) and select the project from 2.

4 - Activate google auth and copy the client id web from Firebase and use THIS code, not the google console one.

I followed a lot of steps but none of them was very specific about this point which is the most strange to me. Please if you need more detail in some point let me know.

@Read1337
Copy link

Read1337 commented Oct 2, 2021

I'm having the same issue. It works on IOS and web but I cannot login in an android device.

@sbellver
Copy link
Author

sbellver commented Oct 26, 2021

I'm still blocked.

If I run

keytool -list -v \
-alias androiddebugkey -keystore ~/.android/debug.keystore

I get an SHA1

If I run @aguirrel solution, I have another one.

Well, I create a new Oauth Credential in https://console.cloud.google.com/apis/credentials?project=MYPROJECT

image

Then, go to firebase: https://console.firebase.google.com/project/MYPROJECT/settings/general/android:my.app

And add the another SHA1 (from Google Maps hint)

image

Then go back to My Credentials, and copy ID KEY from web client

image

And then copy this id into code

image

But no result, always have error API 10

@sjdrew
Copy link

sjdrew commented Nov 26, 2021

And me too with same error. Works on web and ios, but not android. I am just testing in android emulator, but tried with the signed apk and debug with same error.

@sjdrew
Copy link

sjdrew commented Nov 27, 2021

OK I fixed my issue. Turns out it seems the google-services.json I had in place for push notifications then overrides any client key in google api console.

What I did:

  • delete client oauth entry in google api console
  • went to firebase console under project settings - General added my SHA1 keys (release and debug)
  • downloaded new google-services.json
  • grabbed the client_id from the json file in the oauth section "type: 3"
  • used that as the androidClientId in capacitor.config.json
  • the serverClientId is unchanged, still the one from google api console page.

Then bingo, no more error code 10.

@lmfmaier
Copy link

I can't get this to work with capacitor 3.

The dialog with the google account selection shows up but when i select an account it's com.google.android.gms.common.api.ApiException: 10

I'm pretty sure my SHA1 is correct, Gradle signing report and keytool show the same fingerprint and I use it for the android app links too

no matter if I use the android client id or the web client id, it's always exception time

@websystems-dev
Copy link

websystems-dev commented Dec 17, 2021

After many hours with SHA1, keys, clients ID, etc... I finally found (here) the solution that worked for me.
I simply added
<string name="server_client_id">REPLACEME.apps.googleusercontent.com</string>
in this file: android/app/src/main/res/values/strings.xml
Now sign-in progress is OK and no more console error shown.
I did other tests, and I figure out that google-services.json file seems to be useless. If I remove it, everything keeps to work fine.
Even in the capacitor.config.json the value for androidClientId seems to be ininfluent. I tried with a foo value, and I still have no errors. I report this just for reference - i.e: I will keep anyway json file and androidClientId in their places.
I'm using Capacitor 3

@lmfmaier
Copy link

After many hours with SHA1, keys, clients ID, etc... I finally found (here) the solution that worked for me. I simply added <string name="server_client_id">REPLACEME.apps.googleusercontent.com</string> in this file: android/app/src/main/res/values/strings.xml Now sign-in progress is OK and no more console error shown. I did other tests, and I figure out that google-services.json file seems to be useless. If I remove it, everything keeps to work fine. Even in the capacitor.config.json the value for androidClientId seems to be ininfluent. I tried with a foo value, and I still have no errors. I report this just for reference - i.e: I will keep anyway json file and androidClientId in their places. I'm using Capacitor 3

That did the trick!

@mmarifat
Copy link

mmarifat commented Mar 26, 2022

@sjdrew
Thanks man. Saved my day. Though I didn't follow the whole procedure. I just copy-paste the "type: 3" id instead of "type: 1"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants