DImuthuUpe/AndroidPdfViewer

UnsatisfiedLinkError with PDFium on Android 15 Emulator with 16 KB Page Size

yd-threra-and opened this issue · 0 comments

Environment

  • Library version: 3.2.0-beta.1
  • Android version: 15 (Vanilla Ice Cream)
  • Emulator: 16 KB page size

Steps to Reproduce

  1. Create an Android emulator with 16 KB page size following the steps in the Android Developers Guide.
  2. Use the PDF Viewer library to load a PDF document with the following code from some fragment from our demo test app:
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        val outputFile = File(requireContext().filesDir, "sample.pdf")
        if (!outputFile.exists()) {
            try {
                val inputStream: InputStream = requireContext().assets.open("sample.pdf")
                val outputStream = FileOutputStream(outputFile)
                val buffer = ByteArray(1024)
                var length: Int
                while (inputStream.read(buffer).also { length = it } > 0) {
                    outputStream.write(buffer, 0, length)
                }
                outputStream.close()
                inputStream.close()
            } catch (e: IOException) {
                e.printStackTrace()
            }
        }
    
        binding.pdfView.fromFile(outputFile)
            .enableSwipe(true)
            .swipeHorizontal(false)
            .enableDoubletap(true)
            .defaultPage(0)
            .onLoad { nbPages -> /* Do something on load complete */ }
            .onPageError { page, t -> /* Handle page error */ }
            .load()
    }
  3. Observe the error.

Error Log

java.lang.UnsatisfiedLinkError: No implementation found for long com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(int, java.lang.String) (tried Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument and Java_com_shockwave_pdfium_PdfiumCore_nativeOpenDocument__ILjava_lang_String_2) - is the library loaded, e.g. System.loadLibrary?
at com.shockwave.pdfium.PdfiumCore.nativeOpenDocument(Native Method)
at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:135)
at com.github.barteksc.pdfviewer.source.FileSource.createDocument(FileSource.java:38)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:53)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:27)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
at java.lang.Thread.run(Thread.java:1012)

Additional Context

This issue affects applications running on Android 15 with 16 KB page size, not limited to those targeting Android 15. The issue is critical as it impacts our project's ability to function correctly on these environments.

Request

We would appreciate any guidance on resolving this issue or information on upcoming fixes. We are willing to assist with testing or contributing to a solution if needed.

Thank you for your attention to this matter.