Не удается устранить ошибку addOnCompleteListener - PullRequest
0 голосов
/ 28 апреля 2019

Как заголовок, этот блок кода выдает ошибку

        mAuth.createUserWithEmailAndPassword(userId + "@gmail.com", userPw)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
              @Override
              public void onComplete(@NonNull Task<AuthResult> task) {
                if (task.isSuccessful()) {
                  // Sign in success, update UI with the signed-in user's information
                  Log.d("signup: ", "createUserWithEmail:success");
                  FirebaseUser user = mAuth.getCurrentUser();
//                      updateUI(user);
                } else {
                  // If sign in fails, display a message to the user.
                  Log.w("signup: ", "createUserWithEmail:failure", task.getException());
                  Toast.makeText(view.getContext(), "Authentication failed.",
                          Toast.LENGTH_SHORT).show();
//                      updateUI(null);
                }
                // ...
              }
            });

Да, я его где-то скопировал, но все равно выдает ошибку:

Ошибка: подходящий метод не найдендля метода addOnCompleteListener (,>) Task.addOnCompleteListener (Executor, OnCompleteListener) не применяется (рассогласование аргументов; не может быть преобразовано в Executor). Метод Task.addOnCompleteListener (Activity, OnCompleteListener) не применяется (несоответствие преобразованных аргументов) не может быть;

Мой build.gradle для справки

apply plugin: 'com.android.application'

android {
    compileSdkVersion 28
    defaultConfig {
        applicationId "xxx.xx.xxx"
        minSdkVersion 19
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        vectorDrawables.useSupportLibrary = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'com.google.android.material:material:1.0.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'androidx.vectordrawable:vectordrawable:1.0.1'
    implementation 'androidx.annotation:annotation:1.0.2'
    implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation 'com.google.firebase:firebase-core:16.0.8'
    implementation 'com.google.firebase:firebase-auth:16.2.1'
    implementation 'androidx.fragment:fragment:1.0.0'
}

apply plugin: 'com.google.gms.google-services'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...