FireBase API身份验证失败

时间:2019-01-24 18:36:47

标签: java android firebase firebase-authentication

我为android studio项目设置了Firebase用户身份验证。经过测试,我最终得到以下错误

API:此设备上不提供InternalFirebaseAuth.FIREBASE_AUTH_API。

从阅读中看来,这听起来像Firebase的一个经常性错误。 Google是否有关于此问题的最新修补程序的更新,我可以找到的最新更新是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 个答案:

答案 0 :(得分:0)

您必须检查其中一项。 1. SHA1提供给您的应用程序。 2.您的根应用程序上必须具有google-services.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'

在Build上

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

答案 1 :(得分:0)

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

相关问题