有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java FireBase API身份验证失败

我已经为安卓 studio项目设置了firebase用户身份验证。在测试了一些之后,我最终得到了下面的错误

API:InternalFirebaseAuth。FIREBASE_AUTH_API在此设备上不可用

从阅读来看,这可能听起来像是Firebase反复出现的错误。 谷歌最近对这个问题的修复是否有更新,我能找到的最新版本是2017年

我已经在两个独立的设备(Amazon Kindle Fire HD和Xperia S)和一个模拟器上运行了我的项目。他们都犯了同样的错误

private void userLogin() 

    String email = emailText.getText().toString().trim();
    String password = passwordText.getText().toString().trim();

  mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            if (task.isSuccessful()) {
                Intent intent = new Intent(sign_in.this, task_list.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            } else {
                Toast.makeText(getApplicationContext(), task.getException().getMessage(), Toast.LENGTH_SHORT).show();
                Log.e(TAG, "onComplete: Failed = " + task.getException().getMessage());
            }

共 (2) 个答案

  1. # 1 楼答案

    错误是由于使用Amazon kindle fire HD进行测试造成的。kindle使用的FireOS没有Google play服务,因此出现了错误

  2. # 2 楼答案

    你必须检查其中一个。 1.SHA1已提供给您的应用程序。 2.你必须拥有谷歌服务。根应用程序上的json。 3.配置依赖项。 4.确保已启用电子邮件/密码验证。在firebase控制台的“身份验证”选项卡中

    apply plugin: 'com.android.application'
    
    android {
      // ...
    }
    
    dependencies {
      // ...
      implementation 'com.google.firebase:firebase-core:16.0.6'
    
      // Getting a "Could not find" error? Make sure you have
      // added the Google maven respository to your root build.gradle
    }
    
    // ADD THIS AT THE BOTTOM
    apply plugin: 'com.google.gms.google-services'
    

    这是在建的

    buildscript {
        // ...
        dependencies {
            // ...
            classpath 'com.google.gms:google-services:4.2.0' // google-services plugin
        }
    }
    
    allprojects {
        // ...
        repositories {
            google() // Google's Maven repository
            // ...
        }
    }
    

    仅供参考。代码中没有错误。只是设置的东西

    请花点时间做这件事。 Do not skip, do not rush. You will loose more time than saving