繁体   English   中英

导入适用于Android的PDFNet工具会导致应用崩溃

[英]Importing PDFNet Tools for Android causes app to crash

我正在尝试使用PDFTron的PDFNet Android SDK制作pdf云共享解决方案。

我在这里遵循指南:

[适用于Android的PDFNet:入门指南] [1]

我已成功将PDF库添加到我的项目中,并且运行良好。 但是,当我尝试使用上述指南中“添加对注释,文本选择和表单填充的支持”部分中的步骤添加工具库时,应用崩溃,并显示消息“不幸的是,推出PDFEditor已停止”

主要是,我想在日志输出中获得一些帮助。 我尝试使用谷歌搜索没有成功,坦率地说,我无法理解其中的任何一个:

08-05 11:54:08.555: D/ActivityThread(11108): setTargetHeapUtilization:0.25
08-05 11:54:08.555: D/ActivityThread(11108): setTargetHeapIdealFree:8388608
08-05 11:54:08.565: D/ActivityThread(11108): setTargetHeapConcurrentStart:2097152
08-05 11:54:10.157: W/dalvikvm(11108): VFY: unable to resolve static method 963: Lpdftron/PDF/PDFNet;.initialize (Landroid/content/Context;I)V
08-05 11:54:10.157: W/dalvikvm(11108): VFY: unable to resolve exception class 251 (Lpdftron/Common/PDFNetException;)
08-05 11:54:10.157: W/dalvikvm(11108): VFY: unable to find exception handler at addr 0x3c
08-05 11:54:10.157: W/dalvikvm(11108): VFY:  rejected Lcom/pdftron/android/tutorial/pttest/PTTestActivity;.onCreate (Landroid/os/Bundle;)V
08-05 11:54:10.157: W/dalvikvm(11108): VFY:  rejecting opcode 0x0d at 0x003c
08-05 11:54:10.157: W/dalvikvm(11108): VFY:  rejected Lcom/pdftron/android/tutorial/pttest/PTTestActivity;.onCreate (Landroid/os/Bundle;)V
08-05 11:54:10.157: W/dalvikvm(11108): Verifier rejected class Lcom/pdftron/android/tutorial/pttest/PTTestActivity;
08-05 11:54:10.157: W/dalvikvm(11108): Class init failed in newInstance call (Lcom/pdftron/android/tutorial/pttest/PTTestActivity;)
08-05 11:54:10.157: W/dalvikvm(11108): threadid=1: thread exiting with uncaught exception (group=0x41696438)
08-05 11:54:10.177: E/AndroidRuntime(11108): FATAL EXCEPTION: main
08-05 11:54:10.177: E/AndroidRuntime(11108): java.lang.VerifyError: com/pdftron/android/tutorial/pttest/PTTestActivity
08-05 11:54:10.177: E/AndroidRuntime(11108):    at java.lang.Class.newInstanceImpl(Native Method)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at java.lang.Class.newInstance(Class.java:1319)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2025)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at android.app.ActivityThread.access$700(ActivityThread.java:143)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at android.os.Handler.dispatchMessage(Handler.java:99)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at android.os.Looper.loop(Looper.java:137)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at android.app.ActivityThread.main(ActivityThread.java:4967)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at java.lang.reflect.Method.invokeNative(Native Method)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at java.lang.reflect.Method.invoke(Method.java:511)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1011)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:778)
08-05 11:54:10.177: E/AndroidRuntime(11108):    at dalvik.system.NativeStart.main(Native Method)

我不确定是否会有所帮助,但这是我的Activity的代码:

package com.pdftron.android.tutorial.pttest;

import java.io.IOException;
import java.io.InputStream;
import pdftron.Common.PDFNetException;
import pdftron.PDF.PDFDoc;
import pdftron.PDF.PDFNet;
import pdftron.PDF.PDFViewCtrl;
import android.app.Activity;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.Log;

public class PTTestActivity extends Activity 
{
private PDFViewCtrl mPDFViewCtrl;

 @Override
 protected void onCreate(Bundle savedInstanceState) 
 {
     super.onCreate(savedInstanceState);

     // Initialize the library
     try 
     {
         PDFNet.initialize(this, R.raw.pdfnet);
     } 
     catch (PDFNetException e) 
     {
         Log.e("test", "PDFNetException: Line 28");
     }

     // Inflate the view and get a reference to PDFViewCtrl
     setContentView(R.layout.main);
     mPDFViewCtrl = (PDFViewCtrl) findViewById(R.id.pdfviewctrl);

     mPDFViewCtrl.setToolManager(new pdftron.PDF.Tools.ToolManager(mPDFViewCtrl));

     // Load a document
     PDFDoc doc = null;
     Resources res = getResources();
     InputStream is = res.openRawResource(R.raw.sample);


     try 
     {
         doc = new PDFDoc(is);
         // Or you can use the full path instead
         //doc = new PDFDoc("/mnt/sdcard/sample_doc.pdf");
     } 
     catch (PDFNetException e) 
     {
         doc = null;
         Log.e("test", "PDFNetException: Line 50", e);
     } 
     catch (IOException e) 
     {
         doc = null;
         Log.e("test", "IOException: Line 55", e);
     }

     try 
     {
        mPDFViewCtrl.setDoc(doc);
     } 
     catch (PDFNetException e) 
     {
        Log.e("test", "PDFNetException: Line 65", e);
     }
 }

 @Override
 protected void onPause() 
 {
     // This method simply stops the current ongoing rendering thread, text
     // search thread, and tool
     super.onPause();
     if (mPDFViewCtrl != null)
     {
         mPDFViewCtrl.pause();
     }
 }

 @Override
 protected void onResume() 
 {
     // This method simply starts the rendering thread to ensure the PDF
     // content is available for viewing.
     super.onResume();
     if (mPDFViewCtrl != null) 
     {
         mPDFViewCtrl.resume();
     }
 }

 @Override
 protected void onDestroy() 
 {
    // Destroy PDFViewCtrl and clean up memory and used resources.
    super.onDestroy();
    if (mPDFViewCtrl != null) 
    {
        mPDFViewCtrl.destroy();
    }
 }

 @Override
 public void onLowMemory() 
 {
    // Call this method to lower PDFViewCtrl's memory consumption.
    super.onLowMemory();
    if (mPDFViewCtrl != null)       
    {
        mPDFViewCtrl.purgeMemory();
    }
 }
}

这是我的清单:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
          package="com.pdftron.android.tutorial.pttest"
          android:versionCode="1"
          android:versionName="1.0" >
    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="18" />
    <application android:icon="@drawable/rollout" android:label="@string/app_name"      
                 android:theme="@style/AppTheme" android:hardwareAccelerated="true" >
        <activity android:name="PTTestActivity" android:windowSoftInputMode="adjustPan" >
            <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
                 <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

就像我说的那样,我主要想要对日志输出进行某种形式的解释或说明。 我已经为我的代码抛出和捕获的任何异常进行了过滤,但是没有任何显示。

要确保的一件事是,您在解决方案中拥有工具的项目以及自己的项目,而PDFNet.jar在工具的项目中。 另外,您可能要检查PDFNet SDK的文件(.so文件,PDFNet.jar,工具项目本身)之间是否没有版本不匹配,因为您看到的错误可能表明这些文件之间的版本不匹配。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM