-1

我正在尝试使用 Qpdf JAR 文件开发一个 android pdf 阅读器应用程序,他们提供了一个用于 pdf 查看和编辑的示例代码,我遵循 qpdf 参考给出的程序,并相应地对我的应用程序进行了更改,但是当我我在模拟器上运行此应用程序,它已停止。以下是logcat消息,任何人都可以帮助我吗?

08-20 00:26:26.787: E/AndroidRuntime(669): FATAL EXCEPTION: main
08-20 00:26:26.787: E/AndroidRuntime(669): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.pdfreader/com.pdfreader.SamplePDFViewer}: android.view.InflateException: Binary XML file line #7: Error inflating class com.qoppa.samples.viewer.QScrollView
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.app.ActivityThread.access$600(ActivityThread.java:123)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.os.Looper.loop(Looper.java:137)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.app.ActivityThread.main(ActivityThread.java:4424)
08-20 00:26:26.787: E/AndroidRuntime(669):  at java.lang.reflect.Method.invokeNative(Native Method)
08-20 00:26:26.787: E/AndroidRuntime(669):  at java.lang.reflect.Method.invoke(Method.java:511)
08-20 00:26:26.787: E/AndroidRuntime(669):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-20 00:26:26.787: E/AndroidRuntime(669):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-20 00:26:26.787: E/AndroidRuntime(669):  at dalvik.system.NativeStart.main(Native Method)
08-20 00:26:26.787: E/AndroidRuntime(669): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.qoppa.samples.viewer.QScrollView
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
08-20 00:26:26.787: E/AndroidRuntime(669):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.app.Activity.setContentView(Activity.java:1835)
08-20 00:26:26.787: E/AndroidRuntime(669):  at com.pdfreader.SamplePDFViewer.onCreate(SamplePDFViewer.java:30)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.app.Activity.performCreate(Activity.java:4465)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
08-20 00:26:26.787: E/AndroidRuntime(669):  ... 11 more
08-20 00:26:26.787: E/AndroidRuntime(669): Caused by: java.lang.ClassNotFoundException: com.qoppa.samples.viewer.QScrollView
08-20 00:26:26.787: E/AndroidRuntime(669):  at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
08-20 00:26:26.787: E/AndroidRuntime(669):  at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
08-20 00:26:26.787: E/AndroidRuntime(669):  at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.view.LayoutInflater.createView(LayoutInflater.java:552)
08-20 00:26:26.787: E/AndroidRuntime(669):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
08-20 00:26:26.787: E/AndroidRuntime(669):  ... 21 more
4

2 回答 2

1

遇到并解决了这个问题。这可能是由包含“com.qoppa.samples.viewer.QScrollView”的“main.xml”引起的。

    <com.qoppa.samples.viewer.QScrollView
        android:id="@+id/scrollview"
        android:layout_gravity="center"
        android:background="#FFEEEEEE"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <LinearLayout
            android:id="@+id/pagepane"
            android:background="#FFEEEEEE"
            android:gravity="center_horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">
        </LinearLayout>
    </com.qoppa.samples.viewer.QScrollView>

你需要用你自己的类替换它来修复它。为了我:

    <com.example.qiaoruntao.trypdf08.QScrollView
        android:id="@+id/scrollview"
        android:layout_gravity="center"
        android:background="#FFEEEEEE"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <LinearLayout
            android:id="@+id/pagepane"
            android:background="#FFEEEEEE"
            android:gravity="center_horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">
        </LinearLayout>
    </com.example.qiaoruntao.trypdf08.QScrollView>
于 2016-05-03T15:48:13.610 回答
0
Caused by: java.lang.ClassNotFoundException: com.qoppa.samples.viewer.QScrollView 

您可能还没有在清单中声明 QScrollView ?

<activity android:name=".QScrollView"
          android:label="QScrollViewActivity"/>
于 2012-08-19T19:22:12.333 回答