Reputation: 333
I am attempting to view PDFs through my Android app, and I'm using this library: https://www.nuget.org/packages/Xamarin.PdfView.Android/
Here's what my code look likes:
C#:
using Com.Joanzapata.Pdfview;
using Java.IO;
namespace Xamarin_test
{
[Activity(Label = "Xamarin", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
PDFView pdfView = FindViewById<PDFView>(Resource.Id.pdfview);
pdfView.FromAsset("test.pdf")
.DefaultPage(1)
.ShowMinimap(false)
.EnableSwipe(true)
.Load();
}
}
}
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.joanzapata.pdfview.PDFView
android:id="@+id/pdfview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
When I try running it, I receive this error:
Java.Lang.RuntimeException: An error occured while executing doInBackground()
What is causing this?
Thank you.
Edit, Full error log:
Java.Lang.RuntimeException: An error occured while executing doInBackground()
08-17 15:09:23.301 E/AndroidRuntime( 2153): FATAL EXCEPTION: AsyncTask #1
08-17 15:09:23.301 E/AndroidRuntime( 2153): Process: Xamarin_MuPDF.Xamarin_MuPDF, PID: 2153
08-17 15:09:23.301 E/AndroidRuntime( 2153): java.lang.RuntimeException: An error occured while executing doInBackground()
08-17 15:09:23.301 E/AndroidRuntime( 2153): at android.os.AsyncTask$3.done(AsyncTask.java:304)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at java.util.concurrent.FutureTask.run(FutureTask.java:242)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at java.lang.Thread.run(Thread.java:818)
08-17 15:09:23.301 E/AndroidRuntime( 2153): Caused by: java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/Xamarin_MuPDF.Xamarin_MuPDF-1/base.apk"],nativeLibraryDirectories=[/data/app/Xamarin_MuPDF.Xamarin_MuPDF-1/lib/arm64, /vendor/lib64, /system/lib64]]] couldn't find "libvudroid.so"
08-17 15:09:23.301 E/AndroidRuntime( 2153): at java.lang.Runtime.loadLibrary(Runtime.java:367)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at java.lang.System.loadLibrary(System.java:988)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at org.vudroid.core.VuDroidLibraryLoader.load(VuDroidLibraryLoader.java:13)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at org.vudroid.pdfdroid.codec.PdfContext.<clinit>(PdfContext.java:13)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:50)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at com.joanzapata.pdfview.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:1)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at android.os.AsyncTask$2.call(AsyncTask.java:292)
08-17 15:09:23.301 E/AndroidRuntime( 2153): at java.util.concurrent.FutureTask.run(FutureTask.java:237)
08-17 15:09:23.301 E/AndroidRuntime( 2153): ... 3 more
08-17 15:09:26.751 I/Process ( 2153): Sending signal. PID: 2153 SIG: 9
Upvotes: 1
Views: 1094
Reputation: 14750
This happens, because you missed to link the libvudroid.so
. This library is required by pdfview.
You have to
lib
in your Android projectarm64-v8a, armeabi-v7a, armeabi, x86
into the folderlibvudroid.so
into the project and set the properties (right click on the file -> properties)
Troubleshooting
If you get the build error: mandroid error XA0000: Invalid create-package command: ...
Upvotes: 8