English 中文(简体)
e 忽略阅读错误
原标题:eBook reading error

我试图读到一个电子共和国档案,它使用。 尝试该链接中给出的相同样本,但正在获得java.lang.NoClassDefFoundError。 我尽了一切可能。 即便是用针头、剪辑,但能够解决这一问题。 请看一下,并提出一些建议。

04-20 15:08:47.735: E/AndroidRuntime(4329): FATAL EXCEPTION: main
04-20 15:08:47.735: E/AndroidRuntime(4329): java.lang.ExceptionInInitializerError
04-20 15:08:47.735: E/AndroidRuntime(4329):     at com.sample.pubreader.EPubReaderActivity.onCreate(EPubReaderActivity.java:30)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at android.app.ActivityThread.access$1500(ActivityThread.java:132)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at android.os.Looper.loop(Looper.java:143)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at android.app.ActivityThread.main(ActivityThread.java:4196)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at java.lang.reflect.Method.invokeNative(Native Method)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at java.lang.reflect.Method.invoke(Method.java:507)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-20 15:08:47.735: E/AndroidRuntime(4329):     at dalvik.system.NativeStart.main(Native Method)
04-20 15:08:47.735: E/AndroidRuntime(4329): Caused by: java.lang.NoClassDefFoundError: org.slf4j.LoggerFactory
04-20 15:08:47.735: E/AndroidRuntime(4329):     at nl.siegmann.epublib.epub.EpubReader.<clinit>(EpubReader.java:33)
04-20 15:08:47.735: E/AndroidRuntime(4329):     ... 14 more

Eventhough my code is similar to the above link,Im providing the code also.

public class EPubReaderActivity 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("sample.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());
        }
    }
    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("	");
          }
          tocString.append(tocReference.getTitle());
          Log.i("epublib", tocString.toString());

          logTableOfContents(tocReference.getChildren(), depth + 1);
        }
      }
}
最佳回答

我通过增加另外两本杰尔档案来解决这个问题。

slf4j-api and slf4j-simple. 高尔夫球场依赖我提到的图书馆。

感谢您的帮助。

问题回答

Just Add those two mentioned jars in the Libs folder. If the Libs folder is not in project structure, create one and add those jars. The error will go away.





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签