ava.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

纵然是瞬间 提交于 2020-01-14 13:55:15

问题


I am Using docx4j to read Docx file from sd card. I have problem with org.apache.log4j.Logger library. I have even tried to add it externally. but it is still giving me same problem.

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.shvet.pdfreaders"
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    dexOptions {
        incremental true
        javaMaxHeapSize "4g"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support:cardview-v7:23.1.1'
//    compile('org.docx4j:docx4j:2.8.0') {
//        transitive = false
//    }
    compile 'org.apache.logging.log4j:log4j-core:2.5'
    compile files('libs/docx4j-2.8.0.jar')
}

Logcat

02-16 16:15:48.025 24912-24912/com.shvet.pdfreaders E/AndroidRuntime: FATAL EXCEPTION: main Process: com.shvet.pdfreaders, PID: 24912 java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/log4j/Logger; at org.docx4j.openpackaging.Base.(Base.java:42) at com.shvet.pdfreaders.fragments.PdfViewFragment$6.fileSelected(PdfViewFragment.java:205) at com.shvet.pdfreaders.extra.FileChooser$1.onItemClick(FileChooser.java:59) at android.widget.AdapterView.performItemClick(AdapterView.java:305) at android.widget.AbsListView.performItemClick(AbsListView.java:1146) at android.widget.AbsListView$PerformClick.run(AbsListView.java:3057) at android.widget.AbsListView$3.run(AbsListView.java:3864) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:139) at android.app.ActivityThread.main(ActivityThread.java:5298) 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:950) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745) Caused by: java.lang.ClassNotFoundException: Didn't find class "org.apache.log4j.Logger" on path: DexPathList[[zip file "/data/app/com.shvet.pdfreaders-1/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 org.docx4j.openpackaging.Base.(Base.java:42)  at com.shvet.pdfreaders.fragments.PdfViewFragment$6.fileSelected(PdfViewFragment.java:205)  at com.shvet.pdfreaders.extra.FileChooser$1.onItemClick(FileChooser.java:59)  at android.widget.AdapterView.performItemClick(AdapterView.java:305)  at android.widget.AbsListView.performItemClick(AbsListView.java:1146)  at android.widget.AbsListView$PerformClick.run(AbsListView.java:3057)  at android.widget.AbsListView$3.run(AbsListView.java:3864)  at android.os.Handler.handleCallback(Handler.java:739)  at android.os.Handler.dispatchMessage(Handler.java:95)  at android.os.Looper.loop(Looper.java:139)  at android.app.ActivityThread.main(ActivityThread.java:5298)  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:950)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)  Suppressed: java.lang.ClassNotFoundException: org.apache.log4j.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) ... 16 more Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available

What I have done till now: I tried with jar file and external log4j and used gradle url with and without log4j library.

来源:https://stackoverflow.com/questions/35430820/ava-lang-noclassdeffounderror-class-not-found-using-the-boot-class-loader-no-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!