I have spent a few hours (if not days) reading and trying to get this thing working. I want to be able to authenticate users (and let them register) on my app. I've used, among other things, the Firebase console provided in Android Studio to set up the application (so it's registered and linked, and my google-services.json
is indeed in the app
folder).
The resources I've been following (they somehow ALL provide different code snippets, which is super confusing):
- Google's YouTube Firebase PlayList
- FirebaseUI-Android repo on GitHub
- FirebaseUI-Android's explanation for integration
- Firebase's quickstart-android repo on GitHub
- Some Firebase Documentation I'm not sure how to use or if it's even relevant
- I've also implemented a "Login Activity" as proposed as a Template by Android Studio itself.
Screenshot of app's "Sign-in method" settings in the Firebase Console (so yes, I want to integrate those 3 options):
My
Logcat when I test the "Google Sign In Button", after selecting my profile, in my one-and-only half-working Activity (the one that was mostly based off he "quickstart" ressource):
07-16 21:15:39.367 299-987/? E/FastThread: did not receive expected priority boost
07-16 21:15:40.350 842-1252/? E/WifiStateMachine: calculateWifiScore() report new score 56
07-16 21:15:42.892 842-1252/? E/WifiStateMachine: WifiStateMachine CMD_START_SCAN source -2 txSuccessRate=0.05 rxSuccessRate=0.06 targetRoamBSSID=any RSSI=-66
startDelayedScan send -> 62 milli 20000
07-16 21:15:42.893 842-1252/? E/WifiStateMachine: WifiStateMachine CMD_START_SCAN with age=100016 interval=341718 maxinterval=300000
WifiStateMachine CMD_START_SCAN full=false
07-16 21:15:43.370 299-987/? E/FastThread: did not receive expected priority boost
07-16 21:15:43.610 11462-11462/? W/AccountChipsFragment: Recording consent failed.
07-16 21:15:43.641 1701-1701/? W/ChimeraUtils: Non Chimera context
07-16 21:15:43.652 260-260/? W/SurfaceFlinger: couldn't log to binary event log: overflow.
07-16 21:15:43.745 1701-6139/? W/Auth: [GetToken] GetToken failed with status code: UNREGISTERED_ON_API_CONSOLE
07-16 21:15:43.746 9806-10025/? E/TokenRequestor: You have wrong OAuth2 related configurations, please check. Detailed error: UNREGISTERED_ON_API_CONSOLE
07-16 21:15:43.791 11462-11462/? W/AutoManageHelper: Unresolved error while connecting client. Stopping auto-manage.
07-16 21:15:43.862 8178-8178/com.example.payne.simpletestapp W/GoogleActivity: Google sign in failed
com.google.android.gms.common.api.ApiException: 10:
at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source)
at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source)
at com.example.payne.simpletestapp.Authentification.FirebaseActivity.onActivityResult(FirebaseActivity.java:102)
at android.app.Activity.dispatchActivityResult(Activity.java:6218)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3655)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3702)
at android.app.ActivityThread.access$1300(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
07-16 21:15:52.451 842-1252/? E/WifiStateMachine: calculateWifiScore() report new score 60
07-16 21:15:55.480 842-1252/? E/WifiStateMachine: calculateWifiScore() report new score 56
My build.gradle
:
dependencies {
//...
api 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.firebaseui:firebase-ui-auth:4.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
//...
}
apply plugin: 'com.google.gms.google-services'
Part of the other build.gradle
:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.google.gms:google-services:4.0.1'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
NOTE: upgrading to classpath 'com.google.gms:google-services:4.0.2'
gives me the following Logcat after pressing the "Google Sign In Button" and selecting my account:
07-16 21:26:09.488 13118-13118/com.example.payne.simpletestapp W/GoogleActivity: Google sign in failed
com.google.android.gms.common.api.ApiException: 10:
at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(Unknown Source)
at com.google.android.gms.auth.api.signin.GoogleSignIn.getSignedInAccountFromIntent(Unknown Source)
at com.example.payne.simpletestapp.Authentification.FirebaseActivity.onActivityResult(FirebaseActivity.java:102)
at android.app.Activity.dispatchActivityResult(Activity.java:6218)
at android.app.ActivityThread.deliverResults(ActivityThread.java:3655)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:3702)
at android.app.ActivityThread.access$1300(ActivityThread.java:155)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
This is kind of frustrating. I hope you guys can help. I can provide more code if needed... :/
I'm surprised there is no easy way to just copy-paste a bunch of code and get it running. Even setting up the Activity's UI is quite the process. I can't seem to find the specific pieces that I want from the, for example, "FirebaseUI-Android" repo.