2016-09-15 1 views
1

Ich benutze mehrere Bibliotheken für mein Projekt, die ich bei den Abhängigkeiten mit build.gradle, wie Volley und Caligraphy hinzufügen. Ich habe versucht, die Anwendung und das Projekt ganz gut gebaut laufen, aber wenn die Anwendung versucht, eine der externen Bibliotheken zugreifen zu können, ich habe diesen Fehler:NoClassDefFoundError bei Verwendung externer Bibliotheken auf Android Studio

09-15 12:35:30.037 20659-20659/com.node8.peek:background_crash E/AndroidRuntime: FATAL EXCEPTION: main 
    Process: com.node8.peek:background_crash, PID: 20659 
    java.lang.NoClassDefFoundError: Failed resolution of: Luk/co/chrisjenx/calligraphy/CalligraphyConfig$Builder; 
     at com.node8.peek.PeekApplication.onCreate(PeekApplication.java:48) 
     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012) 
     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4593) 
     at android.app.ActivityThread.access$1600(ActivityThread.java:154) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1382) 
     at android.os.Handler.dispatchMessage(Handler.java:102) 
     at android.os.Looper.loop(Looper.java:135) 
     at android.app.ActivityThread.main(ActivityThread.java:5294) 
     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:904) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699) 
    Caused by: java.lang.ClassNotFoundException: Didn't find class "uk.co.chrisjenx.calligraphy.CalligraphyConfig$Builder" on path: DexPathList[[zip file "/data/app/com.node8.peek-6/base.apk"],nativeLibraryDirectories=[/data/app/com.node8.peek-6/lib/arm, /vendor/lib, /system/lib]] 
     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:469) 
     at com.node8.peek.PeekApplication.onCreate(PeekApplication.java:48)  
     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)  
     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4593)  
     at android.app.ActivityThread.access$1600(ActivityThread.java:154)  
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1382)  
     at android.os.Handler.dispatchMessage(Handler.java:102)  
     at android.os.Looper.loop(Looper.java:135)  
     at android.app.ActivityThread.main(ActivityThread.java:5294)  
     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:904)  
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:699)  
    Suppressed: java.lang.ClassNotFoundException: uk.co.chrisjenx.calligraphy.CalligraphyConfig$Builder 
     at java.lang.Class.classForName(Native Method) 
     at java.lang.BootClassLoader.findClass(ClassLoader.java:781) 
     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841) 
     at java.lang.ClassLoader.loadClass(ClassLoader.java:504) 
      ... 13 more 
    Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available 

Ich habe versucht, das Projekt und Invalidate Cache Reinigung & Neustart in Android Studio, aber ich habe immer noch den Fehler. Was könnte diesen Fehler verursacht haben? Das ist mein build.gradle:

buildscript { 
    repositories { 
     mavenCentral() 
     maven { url 'https://maven.fabric.io/public' } 
    } 
    dependencies { 
     classpath 'io.fabric.tools:gradle:1.+' 
     classpath 'com.google.gms:google-services:3.0.0' 
    } 
} 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 
apply plugin: 'android' 
android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 
    packagingOptions { 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/NOTICE.txt' 
    } 
    defaultConfig { 
     applicationId "com.node8.peek" 
     minSdkVersion 21 
     targetSdkVersion 22 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    dexOptions { 
     javaMaxHeapSize "4g" 
    } 
} 
repositories { 
    maven { url "http://jzaccone.github.io/SlidingMenu-aar" } 
    mavenCentral() 
    jcenter(); 
    maven { 
     url "https://jitpack.io" 
    } 
    maven { url 'https://maven.fabric.io/public' } 
} 
dependencies { 
    compile 'com.devbrackets.android:exomedia:3.0.2' 

    compile 'com.github.castorflex.verticalviewpager:library:19.0.1' 
    compile 'uk.co.chrisjenx:calligraphy:2.2.0' 
    compile 'com.jeremyfeinstein.slidingmenu:library:[email protected]' 
    compile 'net.simonvt.menudrawer:menudrawer:[email protected]' 
    compile 'com.sothree.slidinguppanel:library:3.3.0' 
    compile 'com.nikoyuwono:toolbar-panel:0.1.1' 
    compile 'com.android.support:design:22.2.1' 
    compile 'de.hdodenhof:circleimageview:2.0.0' 
    compile 'com.google.android.gms:play-services:9.2.0' 
    compile 'com.splitwise:tokenautocomplete:[email protected]' 
    compile 'com.klinkerapps:android-chips:[email protected]' 
    compile('org.apache.httpcomponents:httpmime:4.3.5') { 
     exclude module: 'org.apache.httpcomponents:httpclient' 
    } 
    compile 'com.android.support:recyclerview-v7:22.2.1' 
    compile('com.github.ganfra:material-spinner:1.1.1') { 
     exclude group: 'com.android.support', module: 'appcompat-v7' 
    } 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile 'com.android.support:appcompat-v7:22.2.1' 
    compile 'com.google.code.gson:gson:2.3.1' 
    compile 'com.facebook.android:facebook-android-sdk:4.8.0' 
    compile 'com.android.support:recyclerview-v7:22.2.1' 
    compile files('libs/javacpp.jar') 
    compile files('libs/twitter4j-core-4.0.4.jar') 
    compile files('libs/javacv.jar') 
    compile project(':volley') 
    compile('com.twitter.sdk.android:twitter:[email protected]') { 
     transitive = true; 
    } 
    compile 'com.google.android.gms:play-services-maps:9.2.0' 
    //compile 'com.google.android.gms:play-services-location:8.1.0' 
    compile 'com.google.maps.android:android-maps-utils:0.4' 
    compile 'com.tumblr:jumblr:0.0.11' 
    compile 'oauth.signpost:signpost-core:1.2.1.2' 
    compile 'oauth.signpost:signpost-commonshttp4:1.2.1.2' 
    compile 'com.theartofdev.edmodo:android-image-cropper:2.2.+' 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
    compile 'com.android.support:multidex:1.0.1' 
    compile 'com.github.jonisaa:MaterialCalendarview:v1.2.2' 
    compile 'com.makeramen:roundedimageview:2.2.1' 
    compile 'com.github.lzyzsd:circleprogress:[email protected]' 
    compile 'com.google.firebase:firebase-core:9.2.0'      // this line must be included to integrate with Firebase 
    compile 'com.google.firebase:firebase-messaging:9.2.0' 
    compile 'com.google.android.gms:play-services-location:9.2.0' 
    compile 'com.google.android.gms:play-services-places:9.2.0' 
    compile 'com.timehop.stickyheadersrecyclerview:library:[email protected]' 

} 
apply plugin: 'com.google.gms.google-services' 

Edit: Ich habe versucht, die Kalligraphie Bibliothek von meinem Projekt zu entfernen, aber jetzt ist die Anwendung gibt, dass Fehler, wenn ich versuche, die Volley-Bibliothek zuzugreifen.

Edit2: Das Aktivieren von Instant Run löste das Problem, aber ich möchte Instant Run nicht verwenden, da dies dazu führte, dass die Anwendung lange Zeit zum Laden benötigte, wenn sie zum ersten Mal installiert wurde. Warum würde die sofortige Ausführung den NoClassDefFoundError verursachen? Gibt es eine Möglichkeit, den Fehler zu vermeiden, ohne Instant Run zu aktivieren?

+0

Werfen Sie einen Blick auf diese https://github.com/chrisjenx/Calligraphy/issues/275 –

+0

Kompilierung 'com.android.support:recyclerview-v7:22.2.1' ist zwei Mal ! – Amit

Antwort

1

Sie können versuchen, Build-Tools z. B. 24, Gradle Plugin, lib, Android Studio auf die neueste Version zu aktualisieren und auch versuchen, das Projekt neu zu erstellen.

+0

Ich habe die BuildtoolsVersion auf '24.0.2 'aktualisiert und das Projekt neu erstellt, aber ich habe immer noch den gleichen Fehler. Ich benutze Android Studio 2.1.3. – nodeDavid

+0

Tatsächlich ist die neueste Version 24.0.3. BTW, hast du diese Lösung versucht http://stackoverflow.com/questions/30503342/noclassdeffounderror-on-calligraphy-library? – UmAnusorn

+0

Ja, meine Anwendung Klasse erweitert bereits MultiDexApplication. – nodeDavid

0

Wenn Sie Android Studio 2.0 verwenden, deaktivieren Sie die Sofortausführung, überprüfen Sie, ob multidex 1.0.1 verwendet wird, und überprüfen Sie, ob Sie MultiDex.init() Before Calligraphy config aufrufen. Hoffnung Es wird dieses Problem lösen.

Ref: https://github.com/chrisjenx/Calligraphy/issues/224

+0

Ich habe das alles gemacht und immer noch den gleichen Fehler. – nodeDavid

Verwandte Themen