Search code examples
androidkotlinpdf-viewerandroidpdfviewer

kotlin androidpdfviewer lib doesn't seem to load


I am working with android pdfviewer lib to open and read a pdf, found at : https://github.com/barteksc/AndroidPdfViewer

But i got an error when i try to launch the pdf :

E/zygote64: 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)

E/PDFView: load pdf error 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)

i tried with differents implementation of the dependency but none worked :

implementation 'com.github.barteksc:pdfium-android:1.9.0'
implementation "com.github.barteksc:android-pdf-viewer:3.2.0-beta.1"
implementation "com.github.barteksc:android-pdf-viewer:2.8.2"

The error is found here :

public PdfDocument newDocument(ParcelFileDescriptor fd, String password) throws IOException {
        PdfDocument document = new PdfDocument();
        document.parcelFileDescriptor = fd;
        synchronized (lock) {
            document.mNativeDocPtr = nativeOpenDocument(getNumFd(fd), password);
        }

        return document;
    }

The fonction nativeOpenDocument from the lib doesn't seem to load.

I found some topic on github talking about it : https://github.com/barteksc/AndroidPdfViewer/issues/538 https://github.com/barteksc/PdfiumAndroid/issues/54 https://github.com/mshockwave/PdfiumAndroid/issues/13

But no solution found, as suggested i tried to change the dependency, tried to shut down my computer and my phone, tried to invalide cache and restart, tried on emulator but nothing work.

It would be very nice if someone could help me with that?


Solution

  • I just found out that in my case i had an app and a module where is my own library aar where i use the androidpdfviewer.

    Probleme was that i had the dependency only on the lib and not the app.

    To solve the probleme i had to add the dependency in both the app and the library. It's seem obvious now that i see that i have 2 build.gradle. Now it's working fine.

    Add classpath 'com.github.barteksc:pdfium-android:1.9.0' in you build.gradle but the project not the module.