Reputation: 51
I'm using several libraries for my project that I add at the dependencies using build.gradle, such as Volley and Caligraphy. I tried to run the application and the project built just fine, but when the application is trying to access one of the external libraries, I got this Error :
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
I've tried cleaning the project and Invalidate Cache & Restart on Android Studio, but I still got the error. What could have caused this error? This is my 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:1.3@aar'
compile 'net.simonvt.menudrawer:menudrawer:3.0.+@aar'
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:2.0.7@aar'
compile 'com.klinkerapps:android-chips:1.0.1@aar'
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:1.13.1@aar') {
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:2.6.0@aar') {
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:1.1.0@aar'
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:0.4.2@aar'
}
apply plugin: 'com.google.gms.google-services'
Edit : I've tried removing the Calligraphy library from my project, but now the application gives that error whenever I'm trying to access the volley library.
Edit2 : Turning on Instant Run solved the problem, but I don't want to use Instant Run if possible since it caused the application to take a long time to load when first installed. Why would instant run caused the NoClassDefFoundError? Is there a way to prevent the error without turning on Instant Run?
Upvotes: 1
Views: 1278
Reputation: 4306
If you are using Android Studio 2.0 then turn off instant run, check multidex 1.0.1 is in use and check that you are calling MultiDex.init() Before Calligraphy config. Hope It will solve that issue.
Ref: https://github.com/chrisjenx/Calligraphy/issues/224
Upvotes: 0
Reputation: 11124
You can try to update build tools e.g.24, gradle plugin, lib, android studio to the latest version and also try to rebuild the project.
Upvotes: 1