PdfiumAndroid icon indicating copy to clipboard operation
PdfiumAndroid copied to clipboard

[Android 15 16KB]Where do the dependent pre-built native libraries come from?

Open robinshi-mega opened this issue 1 year ago • 2 comments

To be able to use this library under Android 15 with 16KB page size enabled, we'd like to rebuild this library, so we could use the library on an Android 15 device with 16KB page size enabled. But It is hard to find out where the 3 pre-built native libraries come from... If anyone can give any clue, that will be much appreciated! Thanks.

  • libmodpng.so - is this the https://github.com/pnggroup/libpng?
  • libmodft2.so - I couldn't figure out what this is.
  • libmodpdfium.so - I assume this is from the Google's pdfium. Is this the one https://pdfium.googlesource.com/pdfium/?

robinshi-mega avatar Sep 23 '24 04:09 robinshi-mega

@robinshi-mega have you managed to rebuild it by any chance? It seems that it might be difficult to find source for libmodft2.so

kkrol2 avatar Oct 10 '24 15:10 kkrol2

@kkrol2 thanks. I haven't yet. :( I guess libmodft2 might be the FreeType2(https://freetype.org/).

robinshi-mega avatar Oct 10 '24 19:10 robinshi-mega

@kkrol2, @robinshi-mega If you guys are still looking for 16kb page size .so files I recently had to update our fork of the PdfiumAndroid library to support it - https://github.com/pCloud/pdfium-core. You can either directly checkout the .so files or follow the BUILD_NATIVE.md guide to build your own pdfium native from starch.

sixtsense avatar Apr 15 '25 09:04 sixtsense

Thank you @sixtsense. We have also managed to build the .so files in repository https://github.com/meganz/PdfiumAndroid. Instead of build the PdfiumCore by ourselves, we downloaded it from https://github.com/bblanchon/pdfium-binaries. 👍

robinshi-mega avatar Apr 15 '25 20:04 robinshi-mega

Thank you @sixtsense. We have also managed to build the .so files in repository https://github.com/meganz/PdfiumAndroid. Instead of build the PdfiumCore by ourselves, we downloaded it from https://github.com/bblanchon/pdfium-binaries. 👍

@robinshi-mega

If im currently using flutter_pdfviwer, which in Android build.gradle uses:

implementation 'com.github.mhiew:android-pdf-viewer:3.2.0-beta.3'

Which has not been updated for 3 years.

How would i go about using your fork?

KPsanz avatar Jul 26 '25 14:07 KPsanz

@KPsanz There is a build.sh under the repo https://github.com/meganz/PdfiumAndroid. bash build.sh will build the PdfiumAndroid code. Parameter --build-png can build png library. Parameter --build-freetype can build freetype library. If the build is successfully, you can find the output in build folder builddir.

robinshi-mega avatar Jul 27 '25 23:07 robinshi-mega

Hi! I've created an updated fork that solves compatibility issues with modern Android development:

https://github.com/ynkfish/PdfiumAndroid

What it fixes: ✅ Android SDK 35 / NDK 28 compatibility ✅ Android Gradle Plugin 8.9.2 support (had some trouble with later AGP versions, might look into this another time) ✅ Android 15 (16KB page size) support ✅ BuildConfig generation issues ✅ Native library packaging in AAR

I'm on Windows, so I've modified the meganz build script to run from Git bash and use ninja build tool.

All build instructions and details are in the README. This fork builds on the excellent work from @barteksc and the meganz (@robinshi-mega) fork. Thanks for the great foundation! 🙏

ynkfish avatar Jul 30 '25 06:07 ynkfish

If anyone looking for the aar file here it is. Thanks @robinshi-mega and @ynkfish For the updates.

https://github.com/chiragthummar/PdfiumAndroid16KB/blob/master/aar/PdfiumAndroid-2.0.0-release.aar

chiragthummar avatar Jul 31 '25 06:07 chiragthummar

@ynkfish and @chiragthummar Why is the minSdkVersion now 26, when it used to be 14?

Aiuspaktyn avatar Aug 01 '25 22:08 Aiuspaktyn

@ynkfish and @chiragthummar Why is the minSdkVersion now 26, when it used to be 14?

I took over the settings from the project in which I was using this library. You might be able to dial it down a few versions if you need a lower min sdk.

ynkfish avatar Aug 02 '25 18:08 ynkfish

Hello @ynkfish I’ve tried adding your library to barteksc/AndroidPdfViewer, and when testing it on an emulator that supports 16KB pages, I get an error — I can’t get pdfium to respond. Have you verified that it works correctly?

my.app                    A  Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x79318777e004 in tid 22611 (my.app), pid 22611 (my.app)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A  Cmdline: my.app

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A  pid: 22611, tid: 22611, name: my.app  >>> my.app <<<

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #01 pc 000000000003e07c  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk!libc++_shared.so (offset 0xc24000) (BuildId: 71ac2d89ae5db431295e18ccf28c26e6b95b216f)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #18 pc 00000000000039e8  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk (offset 0x3c000) (com.shockwave.pdfium.PdfiumCore.<clinit>+0)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #27 pc 0000000000008588  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk (offset 0x44000) (com.github.barteksc.pdfviewer.PDFView.<init>+0)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #51 pc 000000000017d58c  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk (offset 0x13bc000) (androidx.appcompat.app.AppCompatDelegateImpl.setContentView+0)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #56 pc 0000000000178810  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk (offset 0x13bc000) (androidx.appcompat.app.AppCompatActivity.setContentView+0)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #61 pc 0000000000020328  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk (offset 0x148000) (my.app.presentation.PdfViewerActivity.onCreate+0

pcg92 avatar Aug 02 '25 19:08 pcg92

Hello @ynkfish I’ve tried adding your library to barteksc/AndroidPdfViewer, and when testing it on an emulator that supports 16KB pages, I get an error — I can’t get pdfium to respond. Have you verified that it works correctly?

my.app                    A  Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x79318777e004 in tid 22611 (my.app), pid 22611 (my.app)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A  Cmdline: my.app

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A  pid: 22611, tid: 22611, name: my.app  >>> my.app <<<

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #01 pc 000000000003e07c  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk!libc++_shared.so (offset 0xc24000) (BuildId: 71ac2d89ae5db431295e18ccf28c26e6b95b216f)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #18 pc 00000000000039e8  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk (offset 0x3c000) (com.shockwave.pdfium.PdfiumCore.<clinit>+0)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #27 pc 0000000000008588  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk (offset 0x44000) (com.github.barteksc.pdfviewer.PDFView.<init>+0)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #51 pc 000000000017d58c  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk (offset 0x13bc000) (androidx.appcompat.app.AppCompatDelegateImpl.setContentView+0)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #56 pc 0000000000178810  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk (offset 0x13bc000) (androidx.appcompat.app.AppCompatActivity.setContentView+0)

2025-08-02 21:24:16.388 22918-22918 DEBUG                   crash_dump64                         A        #61 pc 0000000000020328  /data/app/~~FD8JN2_pf07LeuhXNPnhFA==/my.app-4Sp97eJdujtsTCog31iUOw==/base.apk (offset 0x148000) (my.app.presentation.PdfViewerActivity.onCreate+0

I've got it working on my phone (android 15), also using AndroidPdfViewer

EDIT: my phone is still on page size 4096 so my test is not valid, I'll have to check with an emulator as well

ynkfish avatar Aug 02 '25 20:08 ynkfish

Hello @ynkfish I’ve tried adding your library to barteksc/AndroidPdfViewer, and when testing it on an emulator that supports 16KB pages, I get an error — I can’t get pdfium to respond. Have you verified that it works correctly?

@pcg92 my app is not compatible with x86, and I can only run an x86 emulator so I can't test. Are you running it on x86 or arm64 emulator?

ynkfish avatar Aug 04 '25 07:08 ynkfish

@

Hello @ynkfish I’ve tried adding your library to barteksc/AndroidPdfViewer, and when testing it on an emulator that supports 16KB pages, I get an error — I can’t get pdfium to respond. Have you verified that it works correctly?

@pcg92 my app is not compatible with x86, and I can only run an x86 emulator so I can't test. Are you running it on x86 or arm64 emulator?

On an arm64 emulator, I managed to get it working—my problem was that the libraries were being loaded twice.

pcg92 avatar Aug 04 '25 07:08 pcg92

@

Hello @ynkfish I’ve tried adding your library to barteksc/AndroidPdfViewer, and when testing it on an emulator that supports 16KB pages, I get an error — I can’t get pdfium to respond. Have you verified that it works correctly?

@pcg92 my app is not compatible with x86, and I can only run an x86 emulator so I can't test. Are you running it on x86 or arm64 emulator?

On an arm64 emulator, I managed to get it working—my problem was that the libraries were being loaded twice.

Great to hear, thanks for the update!

ynkfish avatar Aug 04 '25 07:08 ynkfish

Hi @ynkfish do you know why x86_64 the only abi that has a 4kb section alignment all other abi's are 16kb aligned this is on the libc++_shared.so

Maybe this is not a problem since the x86_64 abi is for emulators?

Image

renzified avatar Aug 22 '25 11:08 renzified

@basurahan I have uploaded the app to the Play Store, and it's working with the given AAR and configs.

chiragthummar avatar Aug 22 '25 11:08 chiragthummar

@basurahan I have uploaded the app to the Play Store, and it's working with the given AAR and configs.

yeah just curious why the x86_64 abi has still 4kb

renzified avatar Aug 22 '25 11:08 renzified

Same problem here: x86_64 abi has still 4kb. I submitted an update to Google Play, but it still has the "does not support 16kb page size" flag. Has anyone managed to fix this?

Image

inkandpaper-app avatar Aug 30 '25 07:08 inkandpaper-app

Hi @inkandpaper-app I fixed it btw here is the latest aar with the fix:

https://github.com/basurahan/PdfiumAndroid/releases/tag/V2.0.1

you can download from the attachments of the release

renzified avatar Aug 30 '25 07:08 renzified

Thanks, it seems to be working now. I've submitted a new update to Google Play, fingers crossed...

inkandpaper-app avatar Aug 30 '25 10:08 inkandpaper-app

that will work you can check on the bundle details on the bundle explorer i checked mine and it says Supports 16kb :-)

renzified avatar Aug 30 '25 10:08 renzified

try AhmerPdfium with PdfViewer

Image

AhmerAfzal1 avatar Aug 30 '25 10:08 AhmerAfzal1

Hi @inkandpaper-app I fixed it btw here is the latest aar with the fix:

https://github.com/basurahan/PdfiumAndroid/releases/tag/V2.0.1

you can download from the attachments of the release

Thanks for the fix! I didn't notice any issue since the app I'm using this library in doesn't support x86/x86_64...

I pulled your fix in my fork as well and I also added a copy command for the libc++_shared.so files in the build.sh script (in case someone would want to rebuild the libraries)

ynkfish avatar Sep 01 '25 12:09 ynkfish

try AhmerPdfium with PdfViewer

Image

can you send me files [x86_64, x86, armeabi-v7a, armeabi-v8a] that your library uses PdfiumAndroid

Maromax-4002 avatar Sep 08 '25 13:09 Maromax-4002

I used my ModPdfium you can also use this bblanchon/pdfium-binaries

AhmerAfzal1 avatar Sep 08 '25 13:09 AhmerAfzal1

I used my ModPdfium you can also use this bblanchon/pdfium-binaries

Can you explain more about ModePdfium upgrading so files from 4kb to 16kb?

Currently, I don't want to change the "io.github.oothp:pdfium-android:1.9.0" library because I rely on it a lot and it's easy to use. I just want to update the so files.

Maromax-4002 avatar Sep 08 '25 13:09 Maromax-4002

For building and using Pdfium in Android, you have a few easy options:

  1. Download prebuilt binaries Go to pdfium-binaries releases download the .tgz packages for all ABIs (without V8), and use them directly in your project.

  2. Build with my ModPdfium project Fork ModPdfium Run the Build PDFium for Android workflow from GitHub Actions. If you need .so files for all ABIs, just enable all in the workflow settings before running. After the workflow finishes, download the artifact (ZIP), extract it, and you’ll have the .so files ready to use.

  3. Use a project with 16kb page size support Instead of building from scratch, you can also use a project that already supports 16k page sizes, like my AhmerPdfium and integrate it directly into your project.

AhmerAfzal1 avatar Sep 08 '25 19:09 AhmerAfzal1

For building and using Pdfium in Android, you have a few easy options:

  1. Download prebuilt binaries Go to pdfium-binaries releases download the .tgz packages for all ABIs (without V8), and use them directly in your project.
  2. Build with my ModPdfium project Fork ModPdfium Run the Build PDFium for Android workflow from GitHub Actions. If you need .so files for all ABIs, just enable all in the workflow settings before running. After the workflow finishes, download the artifact (ZIP), extract it, and you’ll have the .so files ready to use.
  3. Use a project with 16kb page size support Instead of building from scratch, you can also use a project that already supports 16k page sizes, like my AhmerPdfium and integrate it directly into your project.

implementation 'io.github.ahmerafzal1:ahmer-pdfviewer:2.0.1'

implementation 'io.github.ahmerafzal1:ahmer-pdfium:1.9.1'

I downloaded the library and followed the steps of the interface. One problem is that my project is built with Java 8 and it is not compatible with the library because it is built with Kotlin.

Maromax-4002 avatar Sep 08 '25 23:09 Maromax-4002

@KPsanz There is a build.sh under the repo https://github.com/meganz/PdfiumAndroid. bash build.sh will build the PdfiumAndroid code. Parameter --build-png can build png library. Parameter --build-freetype can build freetype library. If the build is successfully, you can find the output in build folder builddir.

Hi @robinshi-mega ,

I'm currently using:

implementation('com.github.barteksc:android-pdf-viewer:3.2.0-beta.1') {
    exclude module: 'support-compat'
}

I encountered the same problem you mentioned: libmodpng.so, libmodft2.so, and libmodpdfium.so are all showing 4 KB LOAD section alignment, but 16 KB is required.

Could you kindly advise how I can properly build or fix this size issue for these libraries? Your guidance would be greatly appreciated.

Thank you!

Seiferai1 avatar Sep 09 '25 02:09 Seiferai1