Firebase登录在Android应用程序上失败

时间:2017-12-04 14:15:33

标签: android firebase kotlin firebase-authentication

我的应用在firebase上登录失败时显示错误.. 在日志中它说 - com,找不到google.firebase.auth。 该怎么办 ?我在firebase控制台中启用了电子邮件/密码登录 这是我的代码。

public override fun onStart(){         super.onStart()

    // Check auth on Activity start
    if (mAuth!!.currentUser != null) {
        onAuthSuccess(mAuth!!.currentUser)
    }
}

private fun signIn() {
    Log.d(TAG, "signIn")
    if (!validateForm()) {
        return
    }

    showProgressDialog()
    val email = mEmailField!!.text.toString()
    val password = mPasswordField!!.text.toString()

    mAuth!!.signInWithEmailAndPassword(email, password)
            .addOnCompleteListener(this) { task ->
                Log.d(TAG, "signIn:onComplete:" + task.isSuccessful)
                hideProgressDialog()

                if (task.isSuccessful) {
                    onAuthSuccess(task.result.user)
                } else {
                    Toast.makeText(this@SignInActivity, "Sign In Failed",
                            Toast.LENGTH_SHORT).show()
                }
            }
}

private fun signUp() {
    Log.d(TAG, "signUp")
    if (!validateForm()) {
        return
    }

    showProgressDialog()
    val email = mEmailField!!.text.toString()
    val password = mPasswordField!!.text.toString()

    mAuth!!.createUserWithEmailAndPassword(email, password)
            .addOnCompleteListener(this) { task ->
                Log.d(TAG, "createUser:onComplete:" + task.isSuccessful)
                hideProgressDialog()

                if (task.isSuccessful) {
                    onAuthSuccess(task.result.user)
                } else {
                    Toast.makeText(this@SignInActivity, "Sign Up Failed",
                            Toast.LENGTH_SHORT).show()
                }
            }
}

这是我的gradle模块

apply plugin: 'com.android.application'

apply plugin: 'kotlin-android'

apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 26
defaultConfig {
    applicationId "appname"
    minSdkVersion 15
    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 {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'

implementation 'com.firebaseui:firebase-ui-database:3.0.0'
implementation 'com.google.android.gms:play-services-auth:11.6.2'
implementation 'com.google.firebase:firebase-auth:11.6.2'
implementation 'com.google.firebase:firebase-database:11.6.2'
implementation 'com.google.firebase:firebase-storage:11.6.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
}




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

我已将firebase版本更改为11.6.2 从11.4.2

0 个答案:

没有答案