My app is crashing due to multidex. Below is the crash log information :
12-23 16:43:12.437 6823-6823/com.rogers.tsc I/MultiDex: VM with version 2.1.0 has multidex support 12-23 16:43:12.438 6823-6823/com.rogers.tsc I/MultiDex: install 12-23 16:43:12.438 6823-6823/com.rogers.tsc I/MultiDex: VM has multidex support, MultiDex support library is disabled. 12-23 16:43:12.462 6823-6823/com.rogers.tsc D/AndroidRuntime: Shutting down VM 12-23 16:43:12.463 6823-6823/com.rogers.tsc E/AndroidRuntime: FATAL EXCEPTION: main Process: com.rogers.tsc, PID: 6823 java.lang.RuntimeException: Unable to get provider com.google.android.gms.measurement.AppMeasurementContentProvider: java.lang.NullPointerException: null reference at android.app.ActivityThread.installProvider(ActivityThread.java:5156) at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) at android.app.ActivityThread.-wrap1(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.NullPointerException: null reference at com.google.android.gms.common.internal.zzx.zzz(Unknown Source) at com.google.android.gms.measurement.internal.zzw.zzaT(Unknown Source) at com.google.android.gms.measurement.AppMeasurementContentProvider.onCreate(Unknown Source) at android.content.ContentProvider.attachInfo(ContentProvider.java:1748) at android.content.ContentProvider.attachInfo(ContentProvider.java:1723) at android.app.ActivityThread.installProvider(ActivityThread.java:5153) at android.app.ActivityThread.installContentProviders(ActivityThread.java:4748) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4688) at android.app.ActivityThread.-wrap1(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
It seems there is some problem with the multidex which is causing the issue. I have already added the multidex support to my application. I also have added compile 'com.android.support:multidex:1.0.0'
to my app gradle.
Here is my application class
public class MyApplication extends Application {
private static TscApplication mApplication;
public static TscApplication getApplication()
{
return mApplication;
}
public Context getApplicationContext(){
return mApplication;
}
@Override
public void onCreate() {
super.onCreate();
mApplication = this;
}
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Whenever I add application class reference in AndroidManifest then only crash is occurring otherwise not if I remove it.
Below is my app.graddle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.app.ysc"
minSdkVersion 15
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.android.support:multidex:1.0.0'
}
apply plugin: 'com.google.gms.google-services'
public class MyApplication extends MultiDexApplication {