Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
881 views
in Technique[技术] by (71.8m points)

android - Exception when authenticating with wrong verification code

I'm using Firebase Phone Authentification to verify users accounts. When I try to authenticate with a wrong verification code, I get an IllegalArgumentException. Is there any way to fix that without using try catch blocks?

Here is the exception message :

java.lang.IllegalArgumentException: Cannot create PhoneAuthCredential without either verificationProof, sessionInfo, or temporaryProof.
                                                                 at com.google.android.gms.common.internal.zzbq.checkArgument(Unknown Source)
                                                                 at com.google.firebase.auth.PhoneAuthCredential.<init>(Unknown Source)
                                                                 at com.google.firebase.auth.PhoneAuthProvider.getCredential(Unknown Source)
                                                                 at com.example.myApp.testFragment$3$4.onClick(testFragment.java:316)
                                                                 at android.view.View.performClick(View.java:5197)
                                                                 at android.view.View$PerformClick.run(View.java:20926)
                                                                 at android.os.Handler.handleCallback(Handler.java:739)
                                                                 at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                 at android.os.Looper.loop(Looper.java:145)
                                                                 at android.app.ActivityThread.main(ActivityThread.java:5951)
                                                                 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:1400)
                                                                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)

And here is the line where I get the error :

PhoneAuthCredential credential = PhoneAuthProvider.getCredential(verificationCode, inputCode);

I'm intentionally using wrong verification code in inputCode and hoping to get an error message instead of the exception.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...