Kotlin - I have a problem - signIN with google, Navigation component

i’m using Navigation component , all seems good except this line (error under ‘this’ ) :

googleSignInClient = GoogleSignIn.getClient(this,gso)

with Simple Activity works fine, the problem show up just in Fragement with Navigation component
any suggestions please ?

Have you checked what’s the error message?
The problem could be anything, you can’t just paste you code, say that there’s an error and expect somebody to find a solution, while providing next to no information.

However, I would guess the problem is that method getClient() is expecting an Activity as the first argument, and you are passing a Fragment, or maybe it’s something else.

2 Likes

Also, when you paste code, please select them and press preformatted text

2 Likes

Looks like you are passing a Fragment into a method that requires a Context. Note that an Activity is a Context but a Fragment has a Context. Have you tried to use getContext() or requireContext() when calling this method?

(Without the error message, this is only a deduction - please post the error message here).

1 Like