Ошибка аутентификации Firebase: я включил опцию электронной почты / пароля - PullRequest
0 голосов
/ 06 июня 2018

Я пытаюсь войти в Firebase с Android, я получаю странные сообщения:

Код Изображение здесь

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 for :: com.butt.mediacalradar из View :: -1 DBQ Enabled :: 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'

1 Ответ

0 голосов
/ 06 июня 2018

Чтобы заставить его работать, используйте последние версии для всех ваших зависимостей:

Сначала измените версию служб Google (Project build.gradle) на:

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'.Должен оставаться только в конце файла.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...