Неразрешенная ссылка - PullRequest
       11

Неразрешенная ссылка

0 голосов
/ 06 августа 2020

Я новичок в этой штуке, я использовал учебник в качестве руководства, я скопировал все правильно из учебника, но когда я хочу запустить приложение, я не могу, потому что появляются следующие предупреждения:

Unresolved reference: isSuccesful
Unresolved reference: result
Unresolved reference: isSuccesful
Unresolved reference: result
Unresolved reference: FirebaseAuth

Вот мой код:

package com.mpdw55.medic_app

import android.content.Intent
import android.os.Bundle
import android.view.View
import androidx.appcompat.app.AlertDialog
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.analytics.FirebaseAnalytics
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import kotlinx.android.synthetic.main.activity_auth.*



class AuthActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {

    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_auth)

    // Analytics Event
    val analytics:FirebaseAnalytics = FirebaseAnalytics.getInstance(this)
    val bundle = Bundle()
    bundle.putString("message", "Integracón de Firebase completa")
    analytics.logEvent("Initscreen", bundle)

    //setup
    setup()
}

private fun setup(){

    title = "Autenticación"

    signUpButton.setOnClickListener {
        if (emailEditTest.text.isNotEmpty() && passwordEditText.text.isNotEmpty()) {

            FirebaseAuth.getInstance()
                .createUserWithEmailAndPassword(emailEditTest.text.toString(),
                    passwordEditText.text.toString()).addOnCompleteListener {}

            if (it.isSuccesful) {
                showHome(it.result?.user?.email?:"", ProviderType.BASIC)

            } else {
                showAlert()

            }

        }
    }

       logInButton.setOnClickListener {
           if (emailEditTest.text.isNotEmpty() && passwordEditText.text.isNotEmpty()) {

               FirebaseAuth.getInstance()
                   .signInWithEmailAndPassword(emailEditTest.text.toString(),
                       passwordEditText.text.toString()).addOnCompleteListener {}

               if (it.isSuccesful) {
                   showHome(it.result?.user?.email?:"", ProviderType.BASIC)

               } else {
                   showAlert()

               }

           }
       }

}

private fun showAlert() {

    val builder = AlertDialog.Builder(this)
    builder.setTitle("Error")
    builder.setMessage("Se ha producido un error autenticando al ususario")
    builder.setPositiveButton("Aceptar", null)
    val dialog: AlertDialog = builder.create()
    dialog.show()
}

private fun showHome(email: String, provider: ProviderType){

    val homeIntent = Intent(this, HomeActivity::class.java).apply {
        putExtra("email", email)
        putExtra("provider", provider.name)
    }
    startActivity(homeIntent)

}

My build.gradle (: app)

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 30
    buildToolsVersion "30.0.1"

defaultConfig {
    applicationId "com.mpdw55.medic_app"
    minSdkVersion 16
    targetSdkVersion 30
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.1'
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.firebase:firebase-core:17.4.4'
    implementation 'com.google.firebase:firebase-analytics:17.4.4'
    implementation 'com.google.firebase:firebase-auth:19.3.2'
    implementation 'com.google.android.gms:play-services-auth:18.1.0'
    implementation 'com.firebaseui:firebase-ui-auth:6.3.0'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

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

Кто-нибудь может мне помочь ??

1 Ответ

0 голосов
/ 07 августа 2020

вы должны попытаться поместить if (it.isSuccesfull) {} else {} между скобками для .addOnCompleteListener, результат должен быть чем-то

FirebaseAuth.getInstance()
            .createUserWithEmailAndPassword(emailEditTest.text.toString(),
                passwordEditText.text.toString()).addOnCompleteListener {

       if (it.isSuccesful) {
            showHome(it.result?.user?.email?:"", ProviderType.BASIC)

        } else {
            showAlert()

        } }

И ошибка должна быть устранена. Вы также должны сделать то же самое для пения.

logInButton.setOnClickListener {
       if (emailEditTest.text.isNotEmpty() && passwordEditText.text.isNotEmpty()) {

           FirebaseAuth.getInstance()
               .signInWithEmailAndPassword(emailEditTest.text.toString(),
                   passwordEditText.text.toString()).addOnCompleteListener {

           if (it.isSuccesful) {
               showHome(it.result?.user?.email?:"", ProviderType.BASIC)

           } else {
               showAlert()

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