Android Question Google authentication is not working (using sample code)

Javier Campo Martinez

Member
Licensed User
Hi guys!!!
I executed the sample code posted in the following link:
https://www.b4x.com/android/forum/threads/firebaseauth-authenticate-your-users.67875/

I followed all the previous configuration steps.

When i click in the button "Sign with Google", it displays my Google accounts. I choose one of them, but there are no further actions. The log shows the following:

B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
FirebaseAuth initialized
** Activity (main) Resume **
onAuthStateChanged: com.google.firebase.auth.internal.zzj@3d2743b5
** Activity (main) Resume **
SignInWithGoogle called
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
SignInWithGoogle.ResultArrived
ResultArrived Error: null
** Activity (main) Resume **

I noticed that the ResultArrived error says "null"

I will appreciate any comments.

Best regards,
 

Javier Campo Martinez

Member
Licensed User
Something is not configured properly. Please put the attached library in the internal libraries folder. It should print the status message instead of 'null'.
Hi Erel ...!!!

This is what i'm getting now, while compiling:
B4X:
File not found: FirebaseAuth.b4x_excluded

Regards,
 
Upvote 0

Javier Campo Martinez

Member
Licensed User
... and now, this:
B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean com.google.android.gms.auth.api.signin.GoogleSignInResult.isSuccess()' on a null object reference

I copied the library attached by you, in the folder "C:\Program Files\Anywhere Software\Basic4android\Libraries"

The "1.bal"'s source code is the same posted in the original thread.

I've attached the Manifesto.

Thanks in advance, and best regards.
 

Attachments

  • AndroidManifest.zip
    1.4 KB · Views: 228
Upvote 0

pedrocam

Member
Licensed User
Longtime User
Same problem happening here.. Google Sign in used to work, now it doesnt. Facebook still works. I updated the SDK repositories and still nothing.. Will try on another computer..

I have put #MultiDex: True
I get: ResultArrived Error: Status{statusCode=DEVELOPER_ERROR, resolution=null}, null

EDIT: FIXED!
Turns out editing on a diferent computer requires you to add a new SHA1 key to your firebase console.

Open B4A as admin and open your project.

Follow point 2 on https://www.b4x.com/android/forum/threads/firebaseauth-authenticate-your-users.67875/ and create a new private key for your b4a. Then go to your firebase console (https://console.firebase.google.com) Go to your project, and project settings, find SHA certificate fingerprints and add fingerprint. Add your SHA1 fingerprint. Make sure your package name matches your Project -> build configurations > package name.

Then download the google-services.json and put it (replace it) in your app's folder.

On B4A go tools -> Clean project.

Close everything and reopen B4A as admin and open your app again. now it should work.
 
Last edited:
Upvote 0

Javier Campo Martinez

Member
Licensed User
@pedrocam thanks for your kind answer. It works now !!!!

My mistakes?
1) B4A's package name was not equal to Firebase's package name. Sorry for this one !!!!
2) I hadn't specified a fingerprint value ( in Firebase ) for my application. I ran keytool in my PC ( the keystore folder was under "C:\Program Files\Anywhere Software\Basic4android" ) in order to obtain the fingerprint value

After fixing the issues above, i downloaded the JSON file and I can put this app to work with Google authentication !!!!

Now, when i'm trying to authenticate with a facebook account, i'm obtaining this screen:
screen_facebook_login.jpg
which -in a few words- means : "you must log in first" (?????)
I dunno if this is an error. But i suppose i must be asked for my user/password.

Log contents ( signing in with facebook ):

B4X:
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
Facebook - ResultArrived: Intent { (has extras) }
Facebook cancel
** Activity (main) Resume **

Thanx in advance, and best regards !!!!

EDIT
B4X:
keytool -exportcert -alias androiddebugkey -keystore "C:\Program Files\Anywhere Software\Basic4android\debug.keystore" | openssl sha1 -binary | openssl base64

Finally, i regenerated ( just in case ) the JSON file, cleaned the project and now I am asked for Facebook's credentials:
screen_facebook_login_OK.jpg

I hope it be helpful for someone.

Regards,
 
Last edited:
Upvote 0
Top