簡體   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