shobhitpuri / custom-google-signin-button

A custom SignInButton for Android that supports 'android:text' attribute, currently not supported by Google's original 'SignInButton'. This library also allows to set button theme to dark or light and is based on Google guidelines.
http://go.shobhitpuri.com/googlesignin
MIT License
78 stars 25 forks source link

com.shobhitpuri.custombuttons.GoogleSignInButton cannot be cast to com.google.android.gms.common.SignInButton #4

Closed PaulZhangIsing closed 6 years ago

PaulZhangIsing commented 6 years ago

I have followed instructions on the mainpage , imported the packages did adjustments to xml file. Then I have do such things in my java file

view.findViewById(R.id.sign_in_button).setOnClickListener(this); SignInButton signInButton = (SignInButton) view.findViewById(R.id.sign_in_button); signInButton.setSize(SignInButton.SIZE_STANDARD); signInButton.setColorScheme(SignInButton.COLOR_LIGHT); }

then it give me error by the time I wanna open the page contains this google login button

com.shobhitpuri.custombuttons.GoogleSignInButton cannot be cast to com.google.android.gms.common.SignInButton

shobhitpuri commented 6 years ago

@PaulZhangIsing Thanks for opening the issue. Can you please double check your imports on top of your Java file. Can you please check if by mistake you've imported com.google.android.gms.common.SignInButton instead of com.shobhitpuri.custombuttons.GoogleSignInButton ?

PaulZhangIsing commented 6 years ago

Thanks I think I could close this issue. Thanks for the help!!!!!

Julius26 commented 5 years ago

The GoogleSignInButton can't work with the default SignInButton. why is this?

shobhitpuri commented 5 years ago

@Julius26 Thanks for the comment. Can you please explain a bit? When you say that 'can't work', do you mean that GoogleSignInButton cannot be casted to SignInButton. This is because if you see the custom GoogleSignInButton implementation, its parent is AppCompatButton and SignInButton parent is FrameLayout. If you want to cast, both can be casted as View for the time being, since they all extend the View class at the end. Hope this answers your query. If not, please feel free to expand on your question. Thanks!

rupakyeware commented 3 years ago

Hi @shobhitpuri my app keeps crashing and I double checked all the corrections you mentioned above but it still won't work. This is the error I am getting Caused by: java.lang.ClassCastException: com.shobhitpuri.custombuttons.GoogleSignInButton cannot be cast to com.google.android.gms.common.SignInButton

Could you please guide me to the solution? Much appreaciated

shobhitpuri commented 3 years ago

@rupakyeware Can you see if below is the issue, else please share the stacktrace and relevant file to help debug further.

@PaulZhangIsing Thanks for opening the issue. Can you please double check your imports on top of your Java file. Can you please check if by mistake you've imported com.google.android.gms.common.SignInButton instead of com.shobhitpuri.custombuttons.GoogleSignInButton ?