I am trying to use the PDFNet Android SDK from PDFTron to make a pdf cloud sharing solution.
I am following the guide here:
[PDFNet for Android: Getting Started Guide][1]
I successfully added the PDF library to my project, and it ran fine. But when I try adding the Tools library using the steps in the section "Adding support for Annotations, Text Selection and Form Filling" from the above guide the app is crashing with the message "Unfortunately, Rollout PDFEditor has stopped"
Mainly, I would like to get some help with the log output. I have tried googling with no success and frankly I can't understand any of it:
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)
I'm not sure if it will help but here is the code for my 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();
}
}
}
And here's my Manifest:
<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>
Like I said, I mainly want some sort explanation or clarification of the log output. I have made a filter for any exceptions that would be thrown and caught by my code but nothing shows up.
One thing to make sure of is that you have the Tool's project in the solution with your own project, and that PDFNet.jar is in the Tool's project. Also, you may want to check that there's no version mismatch amongst the files of the PDFNet SDK (the .so file, PDFNet.jar, the tools project itself), as the error you're seeing could indicate a version mismatch between these files.