电子书阅读错误 [英] eBook reading error

查看:232
本文介绍了电子书阅读错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾尝试阅读EPUB文件使用该即时通讯 http://www.siegmann.nl/ epublib / Android的。我试着这是在给出的链接相同的样品,但即时得到的 java.lang.NoClassDefFoundError的。我尝试了所有的办法,我可以。即使是由ADT改变,食,但我不能能解决这个问题。请查看一下,给我一些建议。

  15 04-20:08:47.735:E / AndroidRuntime(4329):致命异常:主要
04-20 15:08:47.735:E / AndroidRuntime(4329):java.lang.ExceptionInInitializerError
04-20 15:08:47.735:E / AndroidRuntime(4329):在com.sample.pubreader.EPubReaderActivity.onCreate(EPubReaderActivity.java:30)
04-20 15:08:47.735:E / AndroidRuntime(4329):在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
04-20 15:08:47.735:E / AndroidRuntime(4329):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
04-20 15:08:47.735:E / AndroidRuntime(4329):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
04-20 15:08:47.735:E / AndroidRuntime(4329):在android.app.ActivityThread.access $ 1500(ActivityThread.java:132)
04-20 15:08:47.735:E / AndroidRuntime(4329):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1033)
04-20 15:08:47.735:E / AndroidRuntime(4329):在android.os.Handler.dispatchMessage(Handler.java:99)
04-20 15:08:47.735:E / AndroidRuntime(4329):在android.os.Looper.loop(Looper.java:143)
04-20 15:08:47.735:E / AndroidRuntime(4329):在android.app.ActivityThread.main(ActivityThread.java:4196)
04-20 15:08:47.735:E / AndroidRuntime(4329):在java.lang.reflect.Method.invokeNative(本机方法)
04-20 15:08:47.735:E / AndroidRuntime(4329):在java.lang.reflect.Method.invoke(Method.java:507)
04-20 15:08:47.735:E / AndroidRuntime(4329):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)
04-20 15:08:47.735:E / AndroidRuntime(4329):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-20 15:08:47.735:E / AndroidRuntime(4329):在dalvik.system.NativeStart.main(本机方法)
04-20 15:08:47.735:E / AndroidRuntime(4329):java.lang.NoClassDefFoundError的:产生的原因org.slf4j.LoggerFactory
04-20 15:08:47.735:E / AndroidRuntime(4329):在nl.siegmann.epublib.epub.EpubReader< clinit>(EpubReader.java:33)
04-20 15:08:47.735:E / AndroidRuntime(4329):14 ...更多

Eventhough我的code是类似于上面的链接,IM提供code也。

 公共类EPubReaderActivity延伸活动{
    / **当第一次创建活动调用。 * /
    @覆盖
    公共无效的onCreate(捆绑savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);
        AssetManager assetManager = getAssets();
        尝试{
          //找到的InputStream的书
          InputStream的epubInputStream = assetManager
              。开(sample.epub);          从输入流//加载图书
          书书=(新EpubReader())readEpub(epubInputStream)。          //登录这本书的作者
          Log.i(epublib,作者(S):+ book.getMetadata()getAuthors());          //登录书名
          Log.i(epublib,标题:+ book.getTitle());          //登录书的coverimage财产
          位图coverImage = BitmapFactory.de codeStream(book.getCoverImage()
              .getInputStream());
          Log.i(epublib,Coverimage为+ coverImage.getWidth()+由
              + coverImage.getHeight()+像素);          //日志内容的故事
          logTableOfContents(book.getTableOfContents()getTocReferences(),0);
        }赶上(IOException异常五){
          Log.e(epublib,e.getMessage());
        }
    }
    私人无效logTableOfContents(列表< TOCReference> tocReferences,诠释深度){
        如果(tocReferences == NULL){
          返回;
        }
        对于(TOCReference tocReference:tocReferences){
          StringBuilder的tocString =新的StringBuilder();
          的for(int i = 0; I<深度;我++){
            tocString.append(\\ t的);
          }
          tocString.append(tocReference.getTitle());
          Log.i(epublib,tocString.toString());          logTableOfContents(tocReference.getChildren(),深度+ 1);
        }
      }
}


解决方案

我加入另两个jar文件解决了这个问题。

SLF4J的API和SLF4J简单的。该SLF4J,Android已经对我刚才所说的库的依赖。

感谢您的帮助。

I have tried to read a epub file for which im using http://www.siegmann.nl/epublib/android. Im trying the same sample which is given in the link, but im getting java.lang.NoClassDefFoundError . I tried all the way i can. Even by changing by adt,eclipse but i cant able to solve this issue. Please look into it and provide me some suggestions.

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("\t");
          }
          tocString.append(tocReference.getTitle());
          Log.i("epublib", tocString.toString());

          logTableOfContents(tocReference.getChildren(), depth + 1);
        }
      }
}

解决方案

I solved the problem by adding the two another jar files

slf4j-api and slf4j-simple. The slf4j-android has the dependency on the libraries which i have mentioned.

Thanks for your help.

这篇关于电子书阅读错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆