简体   繁体   English

FirebaseNetworkException无法转换为com.google.firebase.auth.FirebaseAuthException

[英]FirebaseNetworkException cannot be cast to com.google.firebase.auth.FirebaseAuthException

There is a cast problem which is FirebaseAuthException. 有一个强制转换问题是FirebaseAuthException。 In some cases, task exception cannot cast to FirebaseAuthException. 在某些情况下,任务异常无法转换为FirebaseAuthException。 How can i handle this situation? 我该如何处理这种情况? I want to try this casting process. 我想试试这个铸造过程。 If it will be success, i will show error with details to user. 如果它会成功,我将向用户显示错误详细信息。 Otherwise If it will not success, i want to show just error. 否则,如果不成功,我想表明只是错误。

   if(task.getException() != null){

    try {
        String errorCode = ((FirebaseAuthException) task.getException()).getErrorCode();

        switch(errorCode) {
            case "ERROR_EMAIL_ALREADY_IN_USE":
                Toast.makeText(LoginActivity.this, LoginActivity.this.getResources().getString(R.string.ERROR_EMAIL_ALREADY_IN_USE),
                        Toast.LENGTH_SHORT).show();
                stopIndicator();
                break;
            case "ERROR_INVALID_EMAIL":
                Toast.makeText(LoginActivity.this, LoginActivity.this.getResources().getString(R.string.ERROR_INVALID_EMAIL),
                        Toast.LENGTH_SHORT).show();
                stopIndicator();
                break;
            case "ERROR_WEAK_PASSWORD":
                Toast.makeText(LoginActivity.this, LoginActivity.this.getResources().getString(R.string.ERROR_WEAK_PASSWORD),
                        Toast.LENGTH_SHORT).show();
                stopIndicator();
                break;
            case "ERROR_CREDENTIAL_ALREADY_IN_USE":
                Toast.makeText(LoginActivity.this, "CREDENTIAL ALREADY IN USE",
                        Toast.LENGTH_SHORT).show();
                stopIndicator();
                break;
            default:
                Toast.makeText(LoginActivity.this, LoginActivity.this.getResources().getString(R.string.Error),
                        Toast.LENGTH_SHORT).show();
                stopIndicator();

        }
    }
    catch (WindowManager.BadTokenException e) {
        Toast.makeText(LoginActivity.this, LoginActivity.this.getResources().getString(R.string.Error),
                Toast.LENGTH_SHORT).show();
        stopIndicator();
    }

}else{
    Toast.makeText(LoginActivity.this, LoginActivity.this.getResources().getString(R.string.Error),
            Toast.LENGTH_SHORT).show();
    stopIndicator();
}
String errorCode;
    if(task.getException()).getErrorCode() instanceof  FirebaseAuthException){
        errorCode = ((FirebaseAuthException) task.getException()).getErrorCode();

        switch(errorCode) {
            case "ERROR_EMAIL_ALREADY_IN_USE":
                Toast.makeText(LoginActivity.this, LoginActivity.this.getResources().getString(R.string.ERROR_EMAIL_ALREADY_IN_USE),
                        Toast.LENGTH_SHORT).show();
                stopIndicator();
                break;
            case "ERROR_INVALID_EMAIL":
                Toast.makeText(LoginActivity.this, LoginActivity.this.getResources().getString(R.string.ERROR_INVALID_EMAIL),
                        Toast.LENGTH_SHORT).show();
                stopIndicator();
                break;
            case "ERROR_WEAK_PASSWORD":
                Toast.makeText(LoginActivity.this, LoginActivity.this.getResources().getString(R.string.ERROR_WEAK_PASSWORD),
                        Toast.LENGTH_SHORT).show();
                stopIndicator();
                break;
            case "ERROR_CREDENTIAL_ALREADY_IN_USE":
                Toast.makeText(LoginActivity.this, "CREDENTIAL ALREADY IN USE",
                        Toast.LENGTH_SHORT).show();
                stopIndicator();
                break;
            default:
                Toast.makeText(LoginActivity.this, LoginActivity.this.getResources().getString(R.string.Error),
                        Toast.LENGTH_SHORT).show();
                stopIndicator();

        }


    }else{
         errorCode="";
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 com.google.firebase.auth.FirebaseAuthException:Firebase ID令牌未由有效的公钥签名 - com.google.firebase.auth.FirebaseAuthException: Firebase ID token isn't signed by a valid public key 错误:程序类型已存在:com.google.firebase.auth.FirebaseAuthException - Error: Program type already present: com.google.firebase.auth.FirebaseAuthException 不能转换为 com.google.firebase.database.DatabaseReference - cannot be cast to com.google.firebase.database.DatabaseReference com.google.firebase.database.Query 不能转换为 com.google.firebase.database.DatabaseReference - com.google.firebase.database.Query cannot be cast to com.google.firebase.database.DatabaseReference Recyclerview 适配器:java.util.ArrayList 无法强制转换为 com.google.ZBF12E1525C25C7AB9A15com.google.ZBF12E1525C25C7AB9A15Z.firestore.F1413SnapshotA15查询 - Recyclerview Adapter: java.util.ArrayList cannot be cast to com.google.firebase.firestore.QuerySnapshot Firebase JAVA管理员SDK FirebaseAuthException - Firebase JAVA admin sdk FirebaseAuthException java:无法访问 com.google.auth.Credentials 未找到 com.google.auth.Credentials 的类文件 - java: cannot access com.google.auth.Credentials class file for com.google.auth.Credentials not found com.google.firebase.auth.firebaseautInvalidUserException:没有与此标识符对应的用户 - com.google.firebase.auth.firebaseautInvalidUserException: there is no user corresponding to this identifier 找不到com.google.firebase.auth的本地模块描述符类 - Local module descriptor class for com.google.firebase.auth not found com.google.gson.internal.LinkedHashTreeMap 无法转换为我的对象 - com.google.gson.internal.LinkedHashTreeMap cannot be cast to my object
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM