3

All of a sudden, when I try to compile my project,and run my app, I start getting this runtime error-

java.lang.NoClassDefFoundError: android.support.v7.app.AppCompatDelegateImplV14
            at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:93)
            at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:77)
            at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:429)
            at android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:57)
            at com.example.shubhamkanodia.bookmybook.MainActivity.onCreate(MainActivity.java:70)
            at android.app.Activity.performCreate(Activity.java:5990)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
            at android.app.ActivityThread.access$800(ActivityThread.java:151)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

Here's what I've tried doing:

1) Excluding support-v4 from all my dependencies and manually specifying an older version, support compile 'com.android.support:support-v4:21.+'.

What is interesting to note is that MainActivity is not my launcher activity. So the app works fine in the launcher activity.. But as soon as mainactivity opens, it fails.

My build.gradle is given below (i had to mess it up a little to fix another another design library bug, so don't mind the excludes )

     compile('com.google.android.gms:play-services-identity:7.5.0') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile('com.android.support:palette-v7:22.2.0') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile('com.nhaarman.listviewanimations:lib-core:3.1.0@aar') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    apt "org.androidannotations:androidannotations:$AAVersion"
    compile ("org.androidannotations:androidannotations-api:$AAVersion")
            {
                exclude module: 'support-v4'
                exclude module: 'support-v7'

            }
    compile('com.android.support:appcompat-v7:22.2.0') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile('com.android.support:cardview-v7:22.2.0') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile('com.android.support:design:22.2.0') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile project(':cognalys')
    compile fileTree(dir: 'libs', include: 'Parse-*.jar')
    compile fileTree(dir: 'libs', include: 'ParseCrashReporting-*.jar')
    compile ('com.google.android.gms:play-services-plus:7.5.0'){
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile ('com.parse.bolts:bolts-android:1.+') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile('com.squareup.picasso:picasso:2.5.2') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile('com.github.ksoichiro:android-observablescrollview:1.5.1') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile ('me.dm7.barcodescanner:zbar:1.7.2') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile('com.sothree.slidinguppanel:library:3.0.0') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile ('com.mcxiaoke.volley:library:1.0.+'){
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile 'com.android.support:support-v4:21.+'
    compile ('jp.wasabeef:picasso-transformations:1.0.3@aar'){
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile ('jp.co.cyberagent.android.gpuimage:gpuimage-library:1.2.3@aar'){
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile ('com.daimajia.easing:library:1.0.1@aar') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    }
    compile('com.daimajia.androidanimations:library:1.1.3@aar') {
        exclude module: 'support-v4'
        exclude module: 'support-v7'

    } 
Shubham Kanodia
  • 6,036
  • 3
  • 32
  • 46

3 Answers3

2

From all the exclusions you exposed, I have to say that what I read is that you just banned support-v4 and support-v7 from your application (even from design and appcompat).

So try to keep them at the end ^^

compile 'com.android.support:appcompat-v7:22.2.0' // no exclusion
shkschneider
  • 17,833
  • 13
  • 59
  • 112
  • compile 'com.android.support:support-v7:22.2.0' is not a valid dependency ( or v7-21.+) for that matter... It keeps saying support library not found - check SDK Manager, even thought I have latest versions intalled – Shubham Kanodia Jun 18 '15 at 16:02
  • Sorry, edited. Include `AppCompat` without exclusion. This way you'll get `support-v4` only from `AppCompat` and only once, because you excluded it everywhere else ^^ – shkschneider Jun 18 '15 at 16:05
  • I cannot use support v4 that comes along with appcomvat-7:22.2, because that will provide me with support v4:22.2. I can only use support v4:21.1.1, hence the excludes. ( https://code.google.com/p/android/issues/detail?can=2&start=0&num=100&q=&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars&groupby=&sort=&id=175086) – Shubham Kanodia Jun 18 '15 at 16:24
  • 1
    If you need to use `support-v4:21.1.1`, why do you include other libraries at version 22.2.0? This shall make conflicts. Have you tried change `appcompat-v7` and others to 21.1.1? – shkschneider Jun 19 '15 at 08:02
  • this helped me : http://stackoverflow.com/questions/27698287/noclassdeffounderror-with-android-studio-on-android-4 – gleroyDroid Jul 14 '15 at 15:01
  • @user1570693 seems unrelated, you are reffering to MultiDex, which solves the "above 65K methods" limit – shkschneider Jul 15 '15 at 09:50
  • As I said. I had the exact same error and search for days until I made this change. I was using multidex to avoid the 65K limit but forgot to Include compile 'com.android.support:multidex:1.0.0 and call MultiDex.install() in my Application. So it was working fine only with recent phones. – gleroyDroid Jul 15 '15 at 15:41
1

for me the solution has been adding

android:name="android.support.multidex.MultiDexApplication"

to the manifest

0

just enable the multidex. That worked for me. follow the link please https://stackoverflow.com/a/31724383/3040893

Community
  • 1
  • 1
smoothumut
  • 3,423
  • 1
  • 25
  • 35