在具有空指针异常的构建文件崩溃应用程序中使用 Multidex 启用 True

Using Multidex enabled True in Build file crash app with Null pointer exception

我正在构建一个社交应用程序,因为我有很多依赖项,所以我在构建文件中使用了 multidex enable true 并类似地添加到清单文件中。但它给我空指针异常错误和应用程序崩溃。

但是当我删除 multidex 时,应用程序运行没有任何错误..请帮助。

我的整个项目是https://github.com/BlueYeti1881/myfirstapp 这是日志猫错误

并构建 gradle 文件是

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.nepalpolice.hometuitionnepal"
        minSdkVersion 16
        targetSdkVersion 27
        vectorDrawables.useSupportLibrary = true
        versionCode 2
         multiDexEnabled true
        versionName "2.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

         lintOptions {
            checkReleaseBuilds false
            abortOnError false
        }

        packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/license.txt'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/project.properties'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/notice.txt'
            exclude 'META-INF/ASL2.0'
            exclude 'allclasses-frame.html'
        }

    }
    dexOptions {
        jumboMode true
    }


    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    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'


    // Support libraries
    implementation 'com.android.support:support-v4:27.1.1'
    implementation 'com.android.support:appcompat-v7:27.1.1'
    implementation 'com.android.support:animated-vector-drawable:27.1.1'
    implementation 'com.android.support:customtabs:27.1.1'
    implementation 'com.android.support:design:27.1.1'
    implementation 'com.android.support:cardview-v7:27.1.1'


    //maps and location





    // Firebase
     implementation 'com.google.firebase:firebase-messaging:11.4.2'
    implementation 'com.google.firebase:firebase-database:11.4.2'
    implementation 'com.google.firebase:firebase-core:11.4.2'
       implementation 'com.google.firebase:firebase-auth:11.4.2'
    implementation 'com.google.firebase:firebase-storage:11.4.2'




    // MVP
    implementation 'com.hannesdorfmann.mosby3:mvp:3.1.0' // Plain MVP

    // Social
    implementation 'com.google.android.gms:play-services-auth:11.4.2'
    implementation 'com.facebook.android:facebook-android-sdk:4.17.0'

    // Images
    implementation 'com.github.bumptech.glide:glide:4.8.0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
    implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.0'
    implementation 'com.android.support.constraint:constraint-layout:1.1.0'





}


apply plugin: 'com.google.gms.google-services'
提前致谢。

After Enabling Multidex

public class Application extends android.app.Application {

    public static final String TAG = Application.class.getSimpleName();

    @Override
    public void onCreate() {
        super.onCreate();

        ApplicationHelper.initDatabaseHelper(this);
        PostInteractor.getInstance(this).subscribeToNewPosts();
    }
}

Replace With

public class Application extends MultiDexApplication {

    public static final String TAG = Application.class.getSimpleName();

    @Override
    public void onCreate() {
        super.onCreate();

        ApplicationHelper.initDatabaseHelper(this);
        PostInteractor.getInstance(this).subscribeToNewPosts();
    }
}