繁体   English   中英

Firebase身份验证错误:我启用了电子邮件/密码选项

[英]Firebase Authentication Error: I Enabled the Email/Password option

我尝试使用Android登录到Firebase,但收到奇怪的消息:

这里的代码图片

login.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            final String Email,Pass;
            Email=email.getText().toString();
            Pass=pass.getText().toString();
            if(!TextUtils.isEmpty(Email) && !TextUtils.isEmpty(Pass))
            {
                progressBar.setVisibility(View.VISIBLE);
                if(Pass.length()>=6)
                {
                    auth = FirebaseAuth.getInstance();
                    auth.signInWithEmailAndPassword(Email, Pass).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task)
                        {
                            progressBar.setVisibility(View.INVISIBLE);
                            if (task.isSuccessful())
                            {
                                Intent i = new Intent(login.this, MainActivity.class);
                                i.putExtra("Email",Email);
                                startActivity(i);
                                finish();
                            }
                            else
                            {
                                progressBar.setVisibility(View.INVISIBLE);
                                Toast.makeText(login.this, "" + task.getException(), Toast.LENGTH_SHORT).show();
                            }
                        }
                    });
                }
                else
                {
                    progressBar.setVisibility(View.INVISIBLE);
                    Toast.makeText(login.this, "Password Must be 8 Character Long", Toast.LENGTH_SHORT).show();
                }

            }
            else
            {
                progressBar.setVisibility(View.INVISIBLE);
                Toast.makeText(login.this, "Provide Email and Password", Toast.LENGTH_SHORT).show();
            }

        }
    });

build.Gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.butt************"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner 

    "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        compile 'com.google.firebase:firebase-database:11.8.0'
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:27.0.1'
        implementation 'com.android.support.constraint:constraint-layout:1.0.2'
        implementation 'com.android.support:support-v4:27.0.1'
        implementation 'com.android.support:recyclerview-v7:27.0.1'
        implementation 'com.google.android.gms:play-services-maps:11.8.0'
        implementation 'com.google.firebase:firebase-database:11.8.0'
        testImplementation 'junit:junit:4.12'
        compile 'com.google.firebase:firebase-auth:11.8.0'
        androidTestImplementation 'com.android.support.test:runner:1.0.1'
        androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
        implementation 'com.android.support:design:27.0.1'
        implementation 'com.android.support:cardview-v7:27.0.1'
        implementation 'com.android.support:gridlayout-v7:27.0.1'
        apply plugin: 'com.google.gms.google-services'
        implementation 'com.google.android.gms:play-services-ads:11.8.0'


    }
    apply plugin: 'com.google.gms.google-services'

与错误消息:

W / BiChannelGoogleApi:[FirebaseAuth:] getGoogleApiForMethod()返回了Gms D / ViewRootImpl:来自应用信息的缓冲区计数,其中::: -1 && -1用于View的:: com.butt.mediacalradar :: -1启用了DBQ :: false false

"com.google.firebase.FirebaseException. An internal Error Occur [Bad Request]".

更新后

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com**********"
        minSdkVersion 19
        targetSdkVersion 26
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    //compile 'com.google.firebase:firebase-database:11.8.0'
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'com.android.support:appcompat-v7:27.0.1'
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:support-v4:27.0.1'
    implementation 'com.android.support:recyclerview-v7:27.0.1'
    implementation 'com.google.android.gms:play-services-maps:15.0.1'
    implementation 'com.google.firebase:firebase-database:16.0.1'
    testImplementation 'junit:junit:4.12'
    compile 'com.google.firebase:firebase-auth:16.0.1'
    androidTestImplementation 'com.android.support.test:runner:1.0.1'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
    implementation 'com.android.support:design:27.0.1'
    implementation 'com.android.support:cardview-v7:27.0.1'
    implementation 'com.android.support:gridlayout-v7:27.0.1'
    apply plugin: 'com.google.gms.google-services'
    implementation 'com.google.android.gms:play-services-ads:15.0.1'


}
apply plugin: 'com.google.gms.google-services'

为了使其正常工作,请为所有依赖项使用最新版本:

首先将Google服务版本(build.gradle Project)更改为:

classpath 'com.google.gms:google-services:4.0.1'

并且依赖项来自:

compile 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.android.gms:play-services-maps:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
compile 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'

//compile 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'

如您所见,第一行被注释。 也不要忘记删除重复的apply plugin: 'com.google.gms.google-services' 应该只保留在文件末尾。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM