psiegman / epublib

a java library for reading and writing epub files
http://www.siegmann.nl/epublib
1.05k stars 317 forks source link

i get this error with the library #40

Open MahmoudMaamoun opened 11 years ago

MahmoudMaamoun commented 11 years ago

here is my code package com.example.almawred;

import android.os.Bundle; import android.app.Activity; import android.view.Menu; 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.content.res.AssetManager; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.util.Log; public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    AssetManager assetManager = getAssets();
    try {
      // find InputStream for book
      InputStream epubInputStream = assetManager.open("georgia-cfi-20120521.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());
    }

}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

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

}

and i get this LogCat error ??

04-01 20:26:41.019: E/epublib(410): georgia-cfi-20120521.epub 04-01 20:30:30.198: E/epublib(439): georgia-cfi-20120521.epub 04-01 20:34:12.268: E/AndroidRuntime(471): FATAL EXCEPTION: main 04-01 20:34:12.268: E/AndroidRuntime(471): java.lang.ExceptionInInitializerError 04-01 20:34:12.268: E/AndroidRuntime(471): at com.example.almawredver2.MainActivity.onCreate(MainActivity.java:32) 04-01 20:34:12.268: E/AndroidRuntime(471): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) 04-01 20:34:12.268: E/AndroidRuntime(471): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700) 04-01 20:34:12.268: E/AndroidRuntime(471): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752) 04-01 20:34:12.268: E/AndroidRuntime(471): at android.app.ActivityThread.access$1500(ActivityThread.java:123) 04-01 20:34:12.268: E/AndroidRuntime(471): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993) 04-01 20:34:12.268: E/AndroidRuntime(471): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 20:34:12.268: E/AndroidRuntime(471): at android.os.Looper.loop(Looper.java:126) 04-01 20:34:12.268: E/AndroidRuntime(471): at android.app.ActivityThread.main(ActivityThread.java:3997) 04-01 20:34:12.268: E/AndroidRuntime(471): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 20:34:12.268: E/AndroidRuntime(471): at java.lang.reflect.Method.invoke(Method.java:491) 04-01 20:34:12.268: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-01 20:34:12.268: E/AndroidRuntime(471): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-01 20:34:12.268: E/AndroidRuntime(471): at dalvik.system.NativeStart.main(Native Method) 04-01 20:34:12.268: E/AndroidRuntime(471): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory 04-01 20:34:12.268: E/AndroidRuntime(471): at nl.siegmann.epublib.epub.EpubReader.(EpubReader.java:33) 04-01 20:34:12.268: E/AndroidRuntime(471): ... 14 more 04-01 20:53:11.058: E/AndroidRuntime(500): FATAL EXCEPTION: main 04-01 20:53:11.058: E/AndroidRuntime(500): java.lang.ExceptionInInitializerError 04-01 20:53:11.058: E/AndroidRuntime(500): at com.example.almawredver2.MainActivity.onCreate(MainActivity.java:32) 04-01 20:53:11.058: E/AndroidRuntime(500): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) 04-01 20:53:11.058: E/AndroidRuntime(500): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700) 04-01 20:53:11.058: E/AndroidRuntime(500): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752) 04-01 20:53:11.058: E/AndroidRuntime(500): at android.app.ActivityThread.access$1500(ActivityThread.java:123) 04-01 20:53:11.058: E/AndroidRuntime(500): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993) 04-01 20:53:11.058: E/AndroidRuntime(500): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 20:53:11.058: E/AndroidRuntime(500): at android.os.Looper.loop(Looper.java:126) 04-01 20:53:11.058: E/AndroidRuntime(500): at android.app.ActivityThread.main(ActivityThread.java:3997) 04-01 20:53:11.058: E/AndroidRuntime(500): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 20:53:11.058: E/AndroidRuntime(500): at java.lang.reflect.Method.invoke(Method.java:491) 04-01 20:53:11.058: E/AndroidRuntime(500): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-01 20:53:11.058: E/AndroidRuntime(500): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-01 20:53:11.058: E/AndroidRuntime(500): at dalvik.system.NativeStart.main(Native Method) 04-01 20:53:11.058: E/AndroidRuntime(500): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory 04-01 20:53:11.058: E/AndroidRuntime(500): at nl.siegmann.epublib.epub.EpubReader.(EpubReader.java:33) 04-01 20:53:11.058: E/AndroidRuntime(500): ... 14 more 04-01 21:11:06.929: E/AndroidRuntime(538): FATAL EXCEPTION: main 04-01 21:11:06.929: E/AndroidRuntime(538): java.lang.ExceptionInInitializerError 04-01 21:11:06.929: E/AndroidRuntime(538): at com.example.almawredver2.MainActivity.onCreate(MainActivity.java:34) 04-01 21:11:06.929: E/AndroidRuntime(538): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) 04-01 21:11:06.929: E/AndroidRuntime(538): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700) 04-01 21:11:06.929: E/AndroidRuntime(538): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752) 04-01 21:11:06.929: E/AndroidRuntime(538): at android.app.ActivityThread.access$1500(ActivityThread.java:123) 04-01 21:11:06.929: E/AndroidRuntime(538): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993) 04-01 21:11:06.929: E/AndroidRuntime(538): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 21:11:06.929: E/AndroidRuntime(538): at android.os.Looper.loop(Looper.java:126) 04-01 21:11:06.929: E/AndroidRuntime(538): at android.app.ActivityThread.main(ActivityThread.java:3997) 04-01 21:11:06.929: E/AndroidRuntime(538): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 21:11:06.929: E/AndroidRuntime(538): at java.lang.reflect.Method.invoke(Method.java:491) 04-01 21:11:06.929: E/AndroidRuntime(538): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-01 21:11:06.929: E/AndroidRuntime(538): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-01 21:11:06.929: E/AndroidRuntime(538): at dalvik.system.NativeStart.main(Native Method) 04-01 21:11:06.929: E/AndroidRuntime(538): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory 04-01 21:11:06.929: E/AndroidRuntime(538): at nl.siegmann.epublib.epub.EpubReader.(EpubReader.java:33) 04-01 21:11:06.929: E/AndroidRuntime(538): ... 14 more 04-01 21:16:25.969: E/AndroidRuntime(572): FATAL EXCEPTION: main 04-01 21:16:25.969: E/AndroidRuntime(572): java.lang.ExceptionInInitializerError 04-01 21:16:25.969: E/AndroidRuntime(572): at com.example.almawredver2.MainActivity.onCreate(MainActivity.java:34) 04-01 21:16:25.969: E/AndroidRuntime(572): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) 04-01 21:16:25.969: E/AndroidRuntime(572): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700) 04-01 21:16:25.969: E/AndroidRuntime(572): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752) 04-01 21:16:25.969: E/AndroidRuntime(572): at android.app.ActivityThread.access$1500(ActivityThread.java:123) 04-01 21:16:25.969: E/AndroidRuntime(572): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993) 04-01 21:16:25.969: E/AndroidRuntime(572): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 21:16:25.969: E/AndroidRuntime(572): at android.os.Looper.loop(Looper.java:126) 04-01 21:16:25.969: E/AndroidRuntime(572): at android.app.ActivityThread.main(ActivityThread.java:3997) 04-01 21:16:25.969: E/AndroidRuntime(572): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 21:16:25.969: E/AndroidRuntime(572): at java.lang.reflect.Method.invoke(Method.java:491) 04-01 21:16:25.969: E/AndroidRuntime(572): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-01 21:16:25.969: E/AndroidRuntime(572): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-01 21:16:25.969: E/AndroidRuntime(572): at dalvik.system.NativeStart.main(Native Method) 04-01 21:16:25.969: E/AndroidRuntime(572): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory 04-01 21:16:25.969: E/AndroidRuntime(572): at nl.siegmann.epublib.epub.EpubReader.(EpubReader.java:33) 04-01 21:16:25.969: E/AndroidRuntime(572): ... 14 more 04-01 21:17:14.818: E/AndroidRuntime(602): FATAL EXCEPTION: main 04-01 21:17:14.818: E/AndroidRuntime(602): java.lang.ExceptionInInitializerError 04-01 21:17:14.818: E/AndroidRuntime(602): at com.example.almawredver2.MainActivity.onCreate(MainActivity.java:34) 04-01 21:17:14.818: E/AndroidRuntime(602): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) 04-01 21:17:14.818: E/AndroidRuntime(602): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700) 04-01 21:17:14.818: E/AndroidRuntime(602): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752) 04-01 21:17:14.818: E/AndroidRuntime(602): at android.app.ActivityThread.access$1500(ActivityThread.java:123) 04-01 21:17:14.818: E/AndroidRuntime(602): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993) 04-01 21:17:14.818: E/AndroidRuntime(602): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 21:17:14.818: E/AndroidRuntime(602): at android.os.Looper.loop(Looper.java:126) 04-01 21:17:14.818: E/AndroidRuntime(602): at android.app.ActivityThread.main(ActivityThread.java:3997) 04-01 21:17:14.818: E/AndroidRuntime(602): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 21:17:14.818: E/AndroidRuntime(602): at java.lang.reflect.Method.invoke(Method.java:491) 04-01 21:17:14.818: E/AndroidRuntime(602): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-01 21:17:14.818: E/AndroidRuntime(602): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-01 21:17:14.818: E/AndroidRuntime(602): at dalvik.system.NativeStart.main(Native Method) 04-01 21:17:14.818: E/AndroidRuntime(602): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory 04-01 21:17:14.818: E/AndroidRuntime(602): at nl.siegmann.epublib.epub.EpubReader.(EpubReader.java:33) 04-01 21:17:14.818: E/AndroidRuntime(602): ... 14 more 04-01 21:46:39.309: E/AndroidRuntime(649): FATAL EXCEPTION: main 04-01 21:46:39.309: E/AndroidRuntime(649): java.lang.ExceptionInInitializerError 04-01 21:46:39.309: E/AndroidRuntime(649): at com.example.almawredver2.MainActivity.onCreate(MainActivity.java:32) 04-01 21:46:39.309: E/AndroidRuntime(649): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) 04-01 21:46:39.309: E/AndroidRuntime(649): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700) 04-01 21:46:39.309: E/AndroidRuntime(649): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752) 04-01 21:46:39.309: E/AndroidRuntime(649): at android.app.ActivityThread.access$1500(ActivityThread.java:123) 04-01 21:46:39.309: E/AndroidRuntime(649): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993) 04-01 21:46:39.309: E/AndroidRuntime(649): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 21:46:39.309: E/AndroidRuntime(649): at android.os.Looper.loop(Looper.java:126) 04-01 21:46:39.309: E/AndroidRuntime(649): at android.app.ActivityThread.main(ActivityThread.java:3997) 04-01 21:46:39.309: E/AndroidRuntime(649): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 21:46:39.309: E/AndroidRuntime(649): at java.lang.reflect.Method.invoke(Method.java:491) 04-01 21:46:39.309: E/AndroidRuntime(649): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-01 21:46:39.309: E/AndroidRuntime(649): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-01 21:46:39.309: E/AndroidRuntime(649): at dalvik.system.NativeStart.main(Native Method) 04-01 21:46:39.309: E/AndroidRuntime(649): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory 04-01 21:46:39.309: E/AndroidRuntime(649): at nl.siegmann.epublib.epub.EpubReader.(EpubReader.java:33) 04-01 21:46:39.309: E/AndroidRuntime(649): ... 14 more 04-01 21:50:10.030: E/AndroidRuntime(684): FATAL EXCEPTION: main 04-01 21:50:10.030: E/AndroidRuntime(684): java.lang.ExceptionInInitializerError 04-01 21:50:10.030: E/AndroidRuntime(684): at com.example.almawredver2.MainActivity.onCreate(MainActivity.java:32) 04-01 21:50:10.030: E/AndroidRuntime(684): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) 04-01 21:50:10.030: E/AndroidRuntime(684): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700) 04-01 21:50:10.030: E/AndroidRuntime(684): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752) 04-01 21:50:10.030: E/AndroidRuntime(684): at android.app.ActivityThread.access$1500(ActivityThread.java:123) 04-01 21:50:10.030: E/AndroidRuntime(684): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993) 04-01 21:50:10.030: E/AndroidRuntime(684): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 21:50:10.030: E/AndroidRuntime(684): at android.os.Looper.loop(Looper.java:126) 04-01 21:50:10.030: E/AndroidRuntime(684): at android.app.ActivityThread.main(ActivityThread.java:3997) 04-01 21:50:10.030: E/AndroidRuntime(684): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 21:50:10.030: E/AndroidRuntime(684): at java.lang.reflect.Method.invoke(Method.java:491) 04-01 21:50:10.030: E/AndroidRuntime(684): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-01 21:50:10.030: E/AndroidRuntime(684): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-01 21:50:10.030: E/AndroidRuntime(684): at dalvik.system.NativeStart.main(Native Method) 04-01 21:50:10.030: E/AndroidRuntime(684): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory 04-01 21:50:10.030: E/AndroidRuntime(684): at nl.siegmann.epublib.epub.EpubReader.(EpubReader.java:33) 04-01 21:50:10.030: E/AndroidRuntime(684): ... 14 more 04-01 21:51:15.119: E/AndroidRuntime(718): FATAL EXCEPTION: main 04-01 21:51:15.119: E/AndroidRuntime(718): java.lang.ExceptionInInitializerError 04-01 21:51:15.119: E/AndroidRuntime(718): at com.example.almawredver2.MainActivity.onCreate(MainActivity.java:32) 04-01 21:51:15.119: E/AndroidRuntime(718): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) 04-01 21:51:15.119: E/AndroidRuntime(718): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700) 04-01 21:51:15.119: E/AndroidRuntime(718): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752) 04-01 21:51:15.119: E/AndroidRuntime(718): at android.app.ActivityThread.access$1500(ActivityThread.java:123) 04-01 21:51:15.119: E/AndroidRuntime(718): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993) 04-01 21:51:15.119: E/AndroidRuntime(718): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 21:51:15.119: E/AndroidRuntime(718): at android.os.Looper.loop(Looper.java:126) 04-01 21:51:15.119: E/AndroidRuntime(718): at android.app.ActivityThread.main(ActivityThread.java:3997) 04-01 21:51:15.119: E/AndroidRuntime(718): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 21:51:15.119: E/AndroidRuntime(718): at java.lang.reflect.Method.invoke(Method.java:491) 04-01 21:51:15.119: E/AndroidRuntime(718): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-01 21:51:15.119: E/AndroidRuntime(718): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-01 21:51:15.119: E/AndroidRuntime(718): at dalvik.system.NativeStart.main(Native Method) 04-01 21:51:15.119: E/AndroidRuntime(718): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory 04-01 21:51:15.119: E/AndroidRuntime(718): at nl.siegmann.epublib.epub.EpubReader.(EpubReader.java:33) 04-01 21:51:15.119: E/AndroidRuntime(718): ... 14 more 04-01 22:05:34.819: E/AndroidRuntime(752): FATAL EXCEPTION: main 04-01 22:05:34.819: E/AndroidRuntime(752): java.lang.ExceptionInInitializerError 04-01 22:05:34.819: E/AndroidRuntime(752): at com.example.almawredver2.MainActivity.onCreate(MainActivity.java:32) 04-01 22:05:34.819: E/AndroidRuntime(752): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) 04-01 22:05:34.819: E/AndroidRuntime(752): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1700) 04-01 22:05:34.819: E/AndroidRuntime(752): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1752) 04-01 22:05:34.819: E/AndroidRuntime(752): at android.app.ActivityThread.access$1500(ActivityThread.java:123) 04-01 22:05:34.819: E/AndroidRuntime(752): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:993) 04-01 22:05:34.819: E/AndroidRuntime(752): at android.os.Handler.dispatchMessage(Handler.java:99) 04-01 22:05:34.819: E/AndroidRuntime(752): at android.os.Looper.loop(Looper.java:126) 04-01 22:05:34.819: E/AndroidRuntime(752): at android.app.ActivityThread.main(ActivityThread.java:3997) 04-01 22:05:34.819: E/AndroidRuntime(752): at java.lang.reflect.Method.invokeNative(Native Method) 04-01 22:05:34.819: E/AndroidRuntime(752): at java.lang.reflect.Method.invoke(Method.java:491) 04-01 22:05:34.819: E/AndroidRuntime(752): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-01 22:05:34.819: E/AndroidRuntime(752): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-01 22:05:34.819: E/AndroidRuntime(752): at dalvik.system.NativeStart.main(Native Method) 04-01 22:05:34.819: E/AndroidRuntime(752): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory 04-01 22:05:34.819: E/AndroidRuntime(752): at nl.siegmann.epublib.epub.EpubReader.(EpubReader.java:33) 04-01 22:05:34.819: E/AndroidRuntime(752): ... 14 more

tbook commented 10 years ago

You simply need to add the library in question. Gradle: compile 'org.slf4j:slf4j-android:1.7.7'