Java.lang.NoClassDefFound using Dagger 2 for Android 4

I have a project where Dagger 2 is used, and I can not run the application on Android 4+, it will work. But on Android 5+, it works fine. So here is the error I get:

08-05 05:03:38.076 25444-25444/app.xqute.com.xqute E/AndroidRuntime﹕ FATAL EXCEPTION: main Process: app.xqute.com.xqute, PID: 25444 java.lang.NoClassDefFoundError: app.xqute.com.xqute.AppModule_ProvideProfileFactory at app.xqute.com.xqute.DaggerApp_AppComponent.initialize(DaggerApp_AppComponent.java:58) at app.xqute.com.xqute.DaggerApp_AppComponent.<init>(DaggerApp_AppComponent.java:50) at app.xqute.com.xqute.DaggerApp_AppComponent.<init>(DaggerApp_AppComponent.java:35) at app.xqute.com.xqute.DaggerApp_AppComponent$Builder.build(DaggerApp_AppComponent.java:151) at app.xqute.com.xqute.App.onCreate(App.java:63) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4328) at android.app.ActivityThread.access$1500(ActivityThread.java:135) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:136) at android.app.ActivityThread.main(ActivityThread.java:5001) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:515) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) at dalvik.system.NativeStart.main(Native Method) 

And here is the build.gradle file with the settings I use:

  apply plugin: 'com.android.application' apply plugin: 'me.tatarka.retrolambda' apply plugin: 'com.neenbedankt.android-apt' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId "app.xqute.com.xqute" multiDexEnabled = true minSdkVersion 15 targetSdkVersion 22 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } signingConfigs { release { storeFile file("xQute.jks") storePassword "saswat123" keyAlias "xQute" keyPassword "saswat123" } } buildTypes { release { minifyEnabled false shrinkResources true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release } } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } lintOptions { abortOnError false } } dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') apt "com.google.dagger:dagger-compiler:2.0" provided 'javax.annotation:jsr250-api:1.0' androidTestCompile 'com.android.support.test:testing-support-lib:0.1' androidTestCompile 'org.assertj:assertj-core:1.6.1' androidTestCompile 'com.squareup.assertj:assertj-android:1.0.0' testCompile 'junit:junit:4.12' testCompile 'org.assertj:assertj-core:1.6.1' compile 'com.android.support:appcompat-v7:22.2.0' compile 'com.google.dagger:dagger:2.0' compile 'com.jakewharton.timber:timber:3.1.0' compile 'com.squareup.retrofit:retrofit:1.9.0' compile 'com.jakewharton:butterknife:6.1.0' compile 'com.facebook.fresco:fresco:0.5.0' compile 'com.google.android.gms:play-services:7.5.0' compile 'com.rengwuxian.materialedittext:library:2.1.3' compile 'com.github.rey5137:material:1.1.1' compile 'com.android.support:support-v4:22.2.0' compile 'com.android.support:recyclerview-v7:22.2.0' testCompile 'org.mockito:mockito-core:1.10.19' compile files('libs/Parse-1.9.2.jar') } configurations { compile.exclude module: 'support-annotations' } 

Any ideas why this works for Android 5+ but not Android 4+?

+7
android dagger-2
source share

No one has answered this question yet.

See similar questions:

14
Why am I still getting java.lang.NoClassDefFoundError: android.support.v7.appcompat.R $ attr?

or similar:

3606
Close / hide Android soft keyboard
3295
Why is the Android emulator so slow? How can we speed up Android emulator development?
3288
Correct use cases for Android UserManager.isUserAGoat ()?
2609
Is there a unique identifier for an Android device?
2510
How to keep Android activity state by saving instance state?
2097
Is there a way to run Python on Android?
1858
"Debug certificate expired" error in Android Eclipse plugins
1844
What is "Context" on Android?
1296
Restart activity during Android rotation
6
java.lang.VerifyError: class rejection X

All Articles