2012-03-07 9 views
0

私は、アセットにepubファイルをロードしてアプリケーションを作成しました。しかし、アプリケーションを実行すると、アプリケーションが予期せず停止したことが表示されます。私は解決策を見つけることができませんでした。参照ごとに次のようにandroidのアセットからepubファイルを実行する方法

符号化法は以下のとおりです。http://www.siegmann.nl/epublib/android

public class EpubActivity 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{ 
      InputStream epubInputStream=assetManager.open("book/budget.epub"); 

      Book book = (new EpubReader()).readEpub(epubInputStream); 

      Log.i("epublib", "author(s): " + book.getMetadata().getAuthors()); 

      Log.i("epublib", "title: " + book.getTitle()); 

      Bitmap coverImage = BitmapFactory.decodeStream(book.getCoverImage() 

         .getInputStream()); 

        Log.i("epublib", "Coverimage is " + coverImage.getWidth() + " by " 

         + coverImage.getHeight() + " pixels"); 


        logTableOfContents(book.getTableOfContents().getTocReferences(), 0); 

     } catch (IOException e) { 

      Log.e("epublib", e.getMessage()); 

     } 
    } 

    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); 

     } 
     } 
    } 

私は私が間違っているつもりですどこか分かりません。 2つのjarファイル(sl4j + epub)が追加されました。しかし、私は出力を得ることができませんでした。

答えて

2

sl4j-apiとsl4j-simpleのようなsl4j-androidの依存関係をlibsフォルダに追加し、libsフォルダを追加してパスを作成する必要があります!!

関連する問題