支持较旧的android版本

时间:2019-02-08 14:20:50

标签: java android firebase

我一直在使用android 8.0版的设备上测试我的应用程序,并且一切都按预期进行,但是今天我还想使用另一个具有较低android版本(android 5.0)的设备进行测试,以确保一切都完美。但令我惊讶的是,该应用在尝试登录或注册具有以下错误的用户时始终崩溃

java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.tasks.Task com.google.android.gms.common.api.GoogleApi.zzb(com.google.android.gms.common.api.internal.zzdd)' on a null object reference
    at com.google.android.gms.internal.zzdvv.zzb(Unknown Source)
    at com.google.android.gms.internal.zzdwc.zzb(Unknown Source)
    at com.google.firebase.auth.FirebaseAuth.signInWithEmailAndPassword(Unknown Source)
    at com.mani.eric.quickchat.LoginActivity.loginuser(LoginActivity.java:100)
    at com.mani.eric.quickchat.LoginActivity.access$300(LoginActivity.java:28)
    at com.mani.eric.quickchat.LoginActivity$1.onClick(LoginActivity.java:80)

这是我的登录活动中发生崩溃的部分

  mAuth.signInWithEmailAndPassword(email, password) //crash occurs here
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {

                        pDialog.dismiss();

                        String current_user_id = mAuth.getCurrentUser().getUid();
                        String tokenID = FirebaseInstanceId.getInstance().getToken();

                        mUserDatabase.child(current_user_id).child("device_token").setValue(tokenID).addOnSuccessListener(new OnSuccessListener<Void>() {
                            @Override
                            public void onSuccess(Void aVoid) {

这是我的build.gradle

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.mani.eric.quickchat"
    minSdkVersion 21
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    targetCompatibility 1.8
    sourceCompatibility 1.8
}
}

dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.firebaseui:firebase-ui-database:1.2.0'
implementation 'id.zelory:compressor:2.0.0'
implementation 'com.squareup.okhttp:okhttp:2.5.0'

implementation 'com.google.firebase:firebase-ads:11.8.0'
implementation 'com.google.firebase:firebase-firestore:11.8.0'

//    implementation "com.github.bumptech.glide:glide:${rootProject.glideVersion}"

//implementation 'com.google.firebase:firebase-inappmessaging-display:17.0.4'

// Check that your Firebase dependency is up-to-date:
implementation 'com.google.firebase:firebase-core:11.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.aurelhubert:ahbottomnavigation:2.0.4'
implementation 'jp.wasabeef:fresco-processors:2.0.0'
implementation "com.facebook.fresco:fresco:0.12.0"
implementation 'jp.co.cyberagent.android.gpuimage:gpuimage-library:1.3.0'
implementation 'com.nex3z:notification-badge:0.2.0'
implementation 'com.github.bumptech.glide:glide:4.8.0'
}

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

0 个答案:

没有答案