Не открывается кнопка "войти с помощью google". В Android Studio с помощью firebase authentication
При написании кода в Android Studio хотел сделать кнопку входа с помощью Google, но при нажатии на кнопку ничего не происходит.
class SignInAct : AppCompatActivity() {
lateinit var launcher: ActivityResultLauncher<Intent>
lateinit var auth: FirebaseAuth
lateinit var binding: ActivitySignInBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivitySignInBinding.inflate(layoutInflater)
setContentView(binding.root)
auth= Firebase.auth
launcher = registerForActivityResult(ActivityResultContracts.StartActivityForResult()){
val task = GoogleSignIn.getSignedInAccountFromIntent(it.data)
try {
val account = task.getResult(ApiException::class.java)
if(account != null){
firebaseAuthWithGoogle(account.idToken!!)
}
} catch (e: ApiException){
Log.d("Mylog", "При подключении возникла ошибка")
}
}
binding.bSignIn.setOnClickListener{
signInWithGoogle()
}
}
private fun getClient(): GoogleSignInClient{
val gso = GoogleSignInOptions
.Builder(GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build()
return GoogleSignIn.getClient(this, gso)
}
private fun signInWithGoogle(){
val signInClient = getClient()
launcher.launch(signInClient.signInIntent)
}
private fun firebaseAuthWithGoogle(idtoken: String){
val credential = GoogleAuthProvider.getCredential(idtoken, null)
auth.signInWithCredential(credential).addOnCompleteListener {
if(it.isSuccessful){
Log.d("Mylog", "Вход через Google прошел успешно")
} else {
Log.d("Mylog", "Вход через Google не удался")
}
}
}
}
Вот такие ошибки в логах:
2022-04-12 12:24:05.664 23722-28120/? E/SignInPerformer-6: Game (com.example.chatparadox) failed to include the Play Games Services application id in their AndroidManifest [CONTEXT service_id=1 ]
2022-04-12 12:24:05.664 23722-28120/? E/PlayGamesServices[SignInPerformer]: The Play Games Services application ID is missing from the Android Manifest. For more information, refer to the troubleshooting guide:
https://developers.google.com/games/services/android/troubleshooting#check_your_metadata_tags
2022-04-12 12:24:42.250 1760-2442/? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8
2022-04-12 12:24:43.098 19031-27052/? E/WakeLock: GCM_HB_ALARM release without a matched acquire!
2022-04-12 12:24:49.167 1874-1874/? E/netmgr: Failed to open QEMU pipe 'qemud:network': Invalid argument
2022-04-12 12:24:56.458 19031-28134/? E/memtrack: Couldn't load memtrack module
2022-04-12 12:27:47.254 23722-28340/? E/SignInPerformer-8: Game (com.example.chatparadox) failed to include the Play Games Services application id in their AndroidManifest [CONTEXT service_id=1 ]