sungaila / PDFtoImage

A .NET library to render PDF files into images.
https://www.sungaila.de/PDFtoImage/
MIT License
152 stars 15 forks source link

System.DllNotFoundException: '/data/data/com.companyname.pos.apphost/files/.__override__/runtimes/android-x64/native/libpdfium.so' #20

Closed hosamyousof closed 1 year ago

hosamyousof commented 1 year ago

I'm testing PDFtoImage.Conversion.ToImage() in .NET MAUI project that targets windows and android. It works fine in windows platform but throws an exception in android:

System.DllNotFoundException: '/data/data/com.companyname.pos.apphost/files/.override/runtimes/android-x64/native/libpdfium.so'

I'm testing on Android Emulator: Android 12.0 - API 31 image

I installed PDFtoImage v2.1.2

Can you please help me solve this issue.

Best regards,

sungaila commented 1 year ago

Hi @hosamyousof,

what is the TargetFramework of this .NET MAUI project? Both net6.0-android21.0 and MonoAndroid 1.0 should include the needed Android binaries.

If it's just net6.0 (or newer) you must add those two missing NuGet packages on your own:

hosamyousof commented 1 year ago

Hi @sungaila,

The target framework is net6.0-android.

sungaila commented 1 year ago

How does the bin folder look like? Is there runtimes/android-x64/native/libpdfium.so copied to the output folder? Or is there a libpdfium.so in the root folder of the output?

hosamyousof commented 1 year ago

I think you mean the target framework should be: net6.0-android31.0 or later not net6.0-android21.0 Like mentioned in this warning: image

I changed the target framework to net6.0-android31.0 and tried but I'm getting the same exception.

Regarding the bin folder: It looks like this image

sungaila commented 1 year ago

I tested .NET MAUI with Android and found the code for loading the libpdfium.so was not working.

Could you please give PDFtoImage 2.1.3 a try?

hosamyousof commented 1 year ago

I appreciate your instance response @sungaila

I've updated the library to 2.1.3 and It's working fine.

Thank you.