NoClassDefFoundError org/slf4j/LoggerFactory;

HI,
Although i am getting this error after including aar in a project but its only java stuff.

I have a project called logging which i wanted to use in another project called Vader. So i made an aar of it.
The build.gradle file for logging is as follows :
apply plugin: 'android-library'
apply plugin: 'maven'

android {
    compileSdkVersion 19
    buildToolsVersion '19.1.0'
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res', 'res-flags']
            assets.srcDirs = ['assets']
        }
    }

    defaultConfig {
        minSdkVersion 14
        targetSdkVersion 19
        versionCode 1
        versionName '1.0'
    }

    lintOptions {
        abortOnError false
    }
}

dependencies {
    compile 'org.slf4j:slf4j-api:1.7.7'
    compile 'com.squareup:tape:1.2.2'
    compile 'com.github.tony19:logback-android-classic:1.1.1-2'
    compile 'to.talk.external:myjson:2.2.4'
}

def coreAarFile = file('build/logging.aar')
artifacts {
    archives coreAarFile
}

uploadArchives {
    repositories {
        mavenDeployer {
            repository(url: "http://ci.aws.talk.to:8081/nexus/content/repositories/snapshots",
                       authentication: [
                               userName: 'deployer',
                               password:'qwedsa'
                       ])
            pom.groupId = 'to.talk.aragorn'
            pom.artifactId = 'logging'
            pom.version = '0.5-SNAPSHOT'
        }
    }
}

Open in new window


After running build in gradle it generated an aar file with name : logging-release.aar which i place in the lib folder of my vader project and add the line :
    compile(name: 'logging', ext: 'aar')
in the build.gradle of the project.
Now i am using one of its function in my project. Although the project compiles perfectly but it gives the following error on runtime :

On Running i am getting the following error :
06-22 18:30:36.797  16634-16634/co.riva.vader E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: co.riva.vader, PID: 16634
    java.lang.NoClassDefFoundError: Failed resolution of: Lorg/slf4j/LoggerFactory;
            at to.talk.logging.LoggerFactory.<clinit>(LoggerFactory.java:37)
            at to.talk.logging.LoggerFactory.getTrimmer(LoggerFactory.java:71)
            at co.riva.vader.HomeActivity.<clinit>(HomeActivity.java:60)
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at java.lang.Class.newInstance(Class.java:1606)
            at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
            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)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "org.slf4j.LoggerFactory" on path: DexPathList[[zip file "/data/app/co.riva.vader-2/base.apk"],nativeLibraryDirectories=[/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 to.talk.logging.LoggerFactory.<clinit>(LoggerFactory.java:37)
            at to.talk.logging.LoggerFactory.getTrimmer(LoggerFactory.java:71)
            at co.riva.vader.HomeActivity.<clinit>(HomeActivity.java:60)
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at java.lang.Class.newInstance(Class.java:1606)
            at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
            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)
    Suppressed: java.lang.ClassNotFoundException: org.slf4j.LoggerFactory
            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)
            ... 18 more

Open in new window


Even though build.gradle inside loggin has the entry for compile 'org.slf4j:slf4j-api:1.7.7'
Still when the aar is included its giving error.
What could be the reason for this. How can i correct it.

Thanks
Rohit BajajAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
What could be the reason for this. How can i correct it.
Because it has a runtime dependency on slf as well. You need to add that
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rohit BajajAuthor Commented:
I included the following
    compile 'org.slf4j:slf4j-simple:1.7.12'
in build.gradle file
But now i am getting the following error :

06-22 19:54:43.337  26759-26759/co.riva.vader E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: co.riva.vader, PID: 26759
    java.lang.NoClassDefFoundError: Failed resolution of: Lch/qos/logback/classic/Logger;
            at to.talk.logging.LoggerFactory.<clinit>(LoggerFactory.java:37)
            at to.talk.logging.LoggerFactory.getTrimmer(LoggerFactory.java:71)
            at co.riva.vader.HomeActivity.<clinit>(HomeActivity.java:60)
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at java.lang.Class.newInstance(Class.java:1606)
            at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
            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)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "ch.qos.logback.classic.Logger" on path: DexPathList[[zip file "/data/app/co.riva.vader-2/base.apk"],nativeLibraryDirectories=[/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 to.talk.logging.LoggerFactory.<clinit>(LoggerFactory.java:37)
            at to.talk.logging.LoggerFactory.getTrimmer(LoggerFactory.java:71)
            at co.riva.vader.HomeActivity.<clinit>(HomeActivity.java:60)
            at java.lang.reflect.Constructor.newInstance(Native Method)
            at java.lang.Class.newInstance(Class.java:1606)
            at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2226)
            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)
    Suppressed: java.lang.ClassNotFoundException: ch.qos.logback.classic.Logger
            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)
            ... 18 more
     Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

Open in new window


It looks like i need to again add some dependency to resolve this further...
How can i resolve it
0
CEHJCommented:
You need to read my comment again - more carefully
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.