Epublib崩溃,Epubreader没有找到类



我有以下错误:

07-03 19:45:47.341 18148-18148/? W/dalvikvm: Exception Ljava/lang/NoClassDefFoundError; thrown while initializing Lnl/siegmann/epublib/epub/EpubReader;
07-03 19:45:47.341 18148-18148/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.bernard.epub3, PID: 18148
java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
at nl.siegmann.epublib.epub.EpubReader.(EpubReader.java:33)
at com.bernard.epub3.Epub3.onCreate(Epub3.java:55)
at android.app.Activity.performCreate(Activity.java:5458)

我设法集成了。jar:它们在libs文件夹和我的构建中。Gradle look包含以下参考

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
    applicationId "com.bernard.epub3"
    minSdkVersion 19
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files ('libs/epublib-core-latest.jar')
compile files ('libs/slf4j-android-1.5.8-sources.jar')
compile 'com.android.support:appcompat-v7:23.4.0'
}

和我的主Java是这样的:

package com.bernard.epub3;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
import nl.siegmann.epublib.domain.Book;
import nl.siegmann.epublib.domain.TOCReference;
import nl.siegmann.epublib.epub.EpubReader;
import android.app.Activity;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
public class Epub3 extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_epub3);
    AssetManager assetManager = getAssets();
    try {
        // find InputStream for book
        InputStream epubInputStream = assetManager
                .open("brit.epub");
        // Load Book from inputStream
        Book book = (new EpubReader()).readEpub(epubInputStream);
        // Log the book's authors
        Log.i("epublib", "author(s): " + book.getMetadata().getAuthors());
        // Log the book's title
        Log.i("epublib", "title: " + book.getTitle());
        // Log the book's coverimage property
        Bitmap coverImage = BitmapFactory.decodeStream(book.getCoverImage()
                .getInputStream());
        Log.i("epublib", "Coverimage is " + coverImage.getWidth() + " by "
                + coverImage.getHeight() + " pixels");
        // Log the tale of contents
        logTableOfContents(book.getTableOfContents().getTocReferences(), 0);
    } catch (IOException e) {
        Log.e("epublib", e.getMessage());
    }
}
/**
 * Recursively Log the Table of Contents
 *
 * @param tocReferences
 * @param depth
 */
private void logTableOfContents(List<TOCReference> tocReferences, int depth) {
    if (tocReferences == null) {
        return;
    }
    for (TOCReference tocReference : tocReferences) {
        StringBuilder tocString = new StringBuilder();
        for (int i = 0; i < depth; i++) {
            tocString.append("t");
        }
        tocString.append(tocReference.getTitle());
        Log.i("epublib", tocString.toString());
        logTableOfContents(tocReference.getChildren(), depth + 1);
    }
}
}

提前感谢您的帮助!

我使用slf4j-android-1.6.1-RC1.jar解决了这个问题

相关内容

  • 没有找到相关文章

最新更新