gpt4 book ai didi

java - 在构建文件崩溃应用程序中使用 Multidex 启用 True 并出现空指针异常

转载 作者:行者123 更新时间:2023-12-02 10:47:13 24 4
gpt4 key购买 nike

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

但是当我删除 multidex 时,应用程序运行时不会出现任何错误..请帮忙。

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

构建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();
}
}

关于java - 在构建文件崩溃应用程序中使用 Multidex 启用 True 并出现空指针异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52465889/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com