2012-05-04 9 views
2

私は、epublibを使用して.epubファイルを表示するアンドロイドで1つのアプリケーションを実装しました。このリンクを1として私のアンドロイドアプリケーションでepublib jarを使用する方法

http://www.siegmann.nl/epublib/android

、私は、次の手順を行っています。

Slf4j-android.
You can download this at http://www.slf4j.org/android/

は、ソースコードと

Download epublib-core-latest.jar from https://github.com/downloads/psiegman/epublib/epublib-core-latest.jar
Download slf4j-android
Add both to your android project

完全な電子書籍リーダーをはじめ。

Eclipse SDKバージョン3.7.2を使用しています。

実行時にこのエラーが発生します。java.lang.NoClassDefFoundError:nl.siegmann.epublib.epub.EpubReader。

私は私にいくつかの解決策を教えてください言及コードの下に

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; 

/** 
* Log the info of 'assets/books/testbook.epub'. 
* 
* @author paul.siegmann 
* 
*/ 
public class LogTestBookInfo extends Activity { 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
    AssetManager assetManager = getAssets(); 
    try { 
     // find InputStream for book 
     InputStream epubInputStream = assetManager 
      .open("books/testbook.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); 
    } 
    } 
} 

を使用していました。あなたは、外部のjarファイルに問題がある場合は

+2

このリンクを参照してくださいhttp://stackoverflow.com/a/10046725/1289716 – MAC

+0

それはあなたのために働くのですか? – MAC

答えて

2

は、あなたが「LIBS」という名前のフォルダを作成する必要があります一つのフォルダという名前のlibs

0

を作成します。次に、そのフォルダに必要なすべてのjarファイルをコピー&ペーストします。 jarファイルは自動的にインクルードされます

関連する問題