CapacitorGoogleAuth icon indicating copy to clipboard operation
CapacitorGoogleAuth copied to clipboard

Problem with new MainActivity.java file.

Open juanmafont opened this issue 3 years ago • 16 comments

Hello. I updated to android studio 4.2.1 and Capacitor 3 plugins. This new updates give an empty MainActivity.java file with only this lines:

package com.aplicationname.app;

import com.getcapacitor.BridgeActivity;

public class MainActivity extends BridgeActivity {
}

then I have to change to:

package com.aplicationname.app;

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

}

juanmafont avatar Jun 03 '21 16:06 juanmafont

Hi @juanmafont I also 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.

Screenshot 2021-06-04 at 5 46 56 PM

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

Hi @juanmafont I also 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.

Screenshot 2021-06-04 at 5 46 56 PM

Check this list:

  • At index.html you added your web key: <meta name="google-signin-client_id" content="653953...82hpe.apps.googleusercontent.com">
  • Into file strings.xml you are using WEB KEY (not android key) : <string name="server_client_id">653953....82hpe.apps.googleusercontent.com</string>
  • Into capacitor.config.json you are usin again WEB KEY (not android key):

"plugins": { "GoogleAuth": { "scopes": [ "profile", "email" ], "serverClientId": "653953.....82hpe.apps.googleusercontent.com", "forceCodeForRefreshToken": true } },

  • Obviously, check MainActivity.java has this lines:

import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth; registerPlugin(GoogleAuth.class);

  • you has a file google-services.json at -> yourapp/android/app with good keys and hash sha1 code.
  • You signed your apk with good sha1 code (same into file google-services.json and same at https://console.firebase.google.com/)
  • At you ionic/angular app your code when initialized authentication is similar to:

constructor() { // Only web if (Capacitor.isNativePlatform() === false) { GoogleAuth.init(); }

.... so be sure only GoogleAuth.init() launched when web (browser), not android or ios.

juanmafont avatar Jun 05 '21 06:06 juanmafont

Hi @juanmafont I also 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. Screenshot 2021-06-04 at 5 46 56 PM

Check this list:

  • At index.html you added your web key: <meta name="google-signin-client_id" content="653953...82hpe.apps.googleusercontent.com">
  • Into file strings.xml you are using WEB KEY (not android key) : <string name="server_client_id">653953....82hpe.apps.googleusercontent.com</string>
  • Into capacitor.config.json you are usin again WEB KEY (not android key):

"plugins": { "GoogleAuth": { "scopes": [ "profile", "email" ], "serverClientId": "653953.....82hpe.apps.googleusercontent.com", "forceCodeForRefreshToken": true } },

  • Obviously, check MainActivity.java has this lines:

import com.codetrixstudio.capacitor.GoogleAuth.GoogleAuth; registerPlugin(GoogleAuth.class);

  • you has a file google-services.json at -> yourapp/android/app with good keys and hash sha1 code.
  • You signed your apk with good sha1 code (same into file google-services.json and same at https://console.firebase.google.com/)
  • At you ionic/angular app your code when initialized authentication is similar to:

constructor() { // Only web if (Capacitor.isNativePlatform() === false) { GoogleAuth.init(); }

.... so be sure only GoogleAuth.init() launched when web (browser), not android or ios.

Hi @juanmafont I used the android keys as you mentioned. Now I am getting the following error.

Screenshot 2021-06-05 at 9 53 35 PM

sumit26-code avatar Jun 05 '21 16:06 sumit26-code

202778109_586862822298065_4100728333317879213_n It's stuck here...

FabioGoncalves avatar Jun 20 '21 02:06 FabioGoncalves

Checkout my solution here: https://github.com/CodetrixStudio/CapacitorGoogleAuth/issues/110#issuecomment-864494481

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

After I pick up the Google account 204119963_1020672535340499_2577850306595115146_n And then it´s always loading ... 202778109_586862822298065_4100728333317879213_n

FabioGoncalves avatar Jun 20 '21 10:06 FabioGoncalves

@FabioGoncalves Can you please share steps and code snippets on how you achieved that. I have spent the past 4-5 days looking for a solution to get it done

codemickey78 avatar Jun 24 '21 08:06 codemickey78

Hi @codemickey78 , I just have this image, image but before you have to settle some requirements, you can find them here: https://github.com/CodetrixStudio/CapacitorGoogleAuth https://devdactic.com/capacitor-google-sign-in/ https://www.youtube.com/watch?v=Rs1imvTbeN0

I tryed today, and it's working so you can do it :)

FabioGoncalves avatar Jun 24 '21 11:06 FabioGoncalves

Hi @codemickey78 , I just have this image, image but before you have to settle some requirements, you can find them here: https://github.com/CodetrixStudio/CapacitorGoogleAuth https://devdactic.com/capacitor-google-sign-in/ https://www.youtube.com/watch?v=Rs1imvTbeN0

I tryed today, and it's working so you can do it :)

Hello @FabioGoncalves,

Can you please explain me that how you resolve the white screen loading issue? Here i got same issue. Still Struck on Android. But web is working. I need to resolve this in android.

Thanks.

iamkbkarthikeyan avatar Jul 04 '21 12:07 iamkbkarthikeyan

Hi @FabioGoncalves and @iamkbkarthikeyan

Did you find a solution ? I have the same issue. It worked on the web but not in Android (emulator Pixel 3 API 30 with Webview Chrome 92). In Android, it stays in the loading state after I picked a Google Account. My env : Ionic CLI 6.17.0 Capacitor 3.1.2 Node 14.17.0 Android Studio Artic Fox 2020.3.1

titib avatar Aug 16 '21 00:08 titib

Hi @codemickey78 , I just have this image, image but before you have to settle some requirements, you can find them here: https://github.com/CodetrixStudio/CapacitorGoogleAuth https://devdactic.com/capacitor-google-sign-in/ https://www.youtube.com/watch?v=Rs1imvTbeN0 I tryed today, and it's working so you can do it :)

Hello @FabioGoncalves,

Can you please explain me that how you resolve the white screen loading issue? Here i got same issue. Still Struck on Android. But web is working. I need to resolve this in android.

Thanks.

Did you resolve it?

FabioGoncalves avatar Aug 24 '21 11:08 FabioGoncalves

Hi @FabioGoncalves and @iamkbkarthikeyan

Did you find a solution? I have the same issue. It worked on the web but not in Android (emulator Pixel 3 API 30 with Webview Chrome 92). In Android, it stays in the loading state after I picked a Google Account. My env : Ionic CLI 6.17.0 Capacitor 3.1.2 Node 14.17.0 Android Studio Artic Fox 2020.3.1

I had the same issue, did you configure all the specs? If so, I just needed to wait, in the next day, I tried again and it worked, maybe some configs that google needed to do? Don't know :D

FabioGoncalves avatar Aug 24 '21 11:08 FabioGoncalves

https://github.com/CodetrixStudio/CapacitorGoogleAuth/issues/116#issuecomment-900725993

Maybe this issue can help :)

FabioGoncalves avatar Aug 24 '21 11:08 FabioGoncalves

I had tried all of the above steps, and it was still getting stuck with a loading screen, after having selected an emailId. Then, I went to the OAuth Consent screen, and added my emailId to the list of Tester emails. and it worked.

Thanks for all the help.

learningRkk avatar Oct 06 '21 09:10 learningRkk

Hi @FabioGoncalves and @iamkbkarthikeyan

Did you find a solution ? I have the same issue. It worked on the web but not in Android (emulator Pixel 3 API 30 with Webview Chrome 92). In Android, it stays in the loading state after I picked a Google Account. My env : Ionic CLI 6.17.0 Capacitor 3.1.2 Node 14.17.0 Android Studio Artic Fox 2020.3.1

Hello, @titib, How are you? This is Bai Feng. I implemented Google Auth in ionic/capacitor3/React. but Google Login not working in the web browser. https://prnt.sc/1wq8wfp https://prnt.sc/1wqey75 this is the screenshots I faced.

could you help me?

timeisgolden avatar Oct 19 '21 13:10 timeisgolden

FabioGoncalves great ! :)

AndreaIaco17 avatar Jun 06 '22 10:06 AndreaIaco17