Android-java.lang.NoClassDefFoundError:无法解决以下问题:Lorg/slf4j/LoggerFactory; [英] Android - java.lang.NoClassDefFoundError: Failed resolution of: Lorg/slf4j/LoggerFactory;

查看:1624
本文介绍了Android-java.lang.NoClassDefFoundError:无法解决以下问题:Lorg/slf4j/LoggerFactory;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经针对此运行时错误进行了一些搜索:

I did some search already regarding this run time error:

java.lang.NoClassDefFoundError:无法解决以下问题:Lorg/slf4j/LoggerFactory

java.lang.NoClassDefFoundError: Failed resolution of: Lorg/slf4j/LoggerFactory

这是我的Android项目中的库":

and here's the "libs" in my Android project:

如您所见,在其中 slf4j-android-1.7.25.jar .我还尝试了最新的slf4j-android-1.7.30.jar,仍然遇到了这个问题.

As you can see, slf4j-android-1.7.25.jar in there. I also tried latest slf4j-android-1.7.30.jar, still having this issue.

基本上,我正在尝试将MS WORD文件转换为pdf,这是我正在尝试在某处找到的代码:

Basically, I am trying to convert MS WORD file to pdf and here's the code I am trying which I found somewhere:

public static void docToPdf(InputStream is, String outputPath){       
    WordprocessingMLPackage wordMLPackage = null;
    try {
        wordMLPackage = WordprocessingMLPackage.load(is);
    } catch (Docx4JException e) {
        e.printStackTrace();
    }
    List sections = wordMLPackage.getDocumentModel().getSections();
    for (int i = 0; i < sections.size(); i++) {
        wordMLPackage.getDocumentModel().getSections().get(i)
                .getPageDimensions();
    }
    Mapper fontMapper = new IdentityPlusMapper();
    PhysicalFont font = PhysicalFonts.getPhysicalFonts().get(
            "Comic Sans MS");//set your desired font
    fontMapper.getFontMappings().put("Algerian", font);
    try {
        wordMLPackage.setFontMapper(fontMapper);
    } catch (Exception e) {
        e.printStackTrace();
    }
   /* PdfSettings pdfSettings = new PdfSettings();
    org.docx4j.convert.out.pdf.PdfConversion conversion = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion(
            wordMLPackage);
    //To turn off logger
    List<Logger> loggers = Collections.<Logger> list(LogManager. getCurrentLoggers());
    loggers.add(LogManager.getRootLogger());
    for (Logger logger : loggers) {
        logger.setLevel(Level.OFF);
    }*/
    OutputStream out = null;
    try {
        out = new FileOutputStream(new File(outputPath));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    /*conversion.output(out, pdfSettings);*/
    try {
        Docx4J.toPDF(wordMLPackage, out);
    } catch (Docx4JException e) {
        e.printStackTrace();
    }
    System.out.println("DONE!!");
}

进一步在控制台中,我可以看到另一条错误消息:

Further down in console, I can see another error message:

原因:java.lang.ClassNotFoundException:在路径:DexPathList [[zip文件"/system/framework/org.apache.http.legacy.boot.jar""上找不到类"org.slf4j.LoggerFactory" ,...

Caused by: java.lang.ClassNotFoundException: Didn't find class "org.slf4j.LoggerFactory" on path: DexPathList[[zip file "/system/framework/org.apache.http.legacy.boot.jar", ...

推荐答案

您需要在lib文件夹中添加slf4j-api-1.7.30.jar. slf4j-api.jar中提供了org.slf4j.LoggerFactory类.

You need to add slf4j-api-1.7.30.jar in lib folder. As org.slf4j.LoggerFactory class is available in slf4j-api.jar.

SLF4J发行版下载最新的jar文件.

Download the latest jar file from SLF4J distribution.

这篇关于Android-java.lang.NoClassDefFoundError:无法解决以下问题:Lorg/slf4j/LoggerFactory;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆