Android Question PDFium library 16 KB question.

Alex_197

Well-Known Member
Licensed User
Longtime User
Hi all.

I have a question. Since the PDFium library is a only option to open a PDF and this lib is not 16KB compatible - are there any option to update this lib?

I tried to update the Pdfium.aar according to https://www.b4x.com/android/forum/t...ot-support-16kb-alignment.168440/post-1032482

I downloaded PdfiumAndroid-2.0.0-release.aar from https://github.com/chiragthummar/PdfiumAndroid16KB/blob/master/aar/PdfiumAndroid-2.0.0-release.aar, opened with 7zip and replaced .so files in Pdfium.aar with so files from PdfiumAndroid-2.0.0-release.aar.

Then I compiled a project in Release mode and tried to check the apk with this script https://www.b4x.com/android/forum/threads/script-to-check-compatibility-16kb.168429/

So far so good.


Then I checked the apk with the chatgpt and the chat says that even though the script shows that the apk is Ok it doesn't.

That's what the chatGPT says


❌ This APK is NOT 16-KB compatible


I checked every native library in:



PDFiumEx.apk → lib/arm64-v8a/


and NONE of the .so files meet the Android 16 KB page-size requirement.




🔍 Why?​


For each LOAD segment, the alignment must be:



0x4000 = 16384 bytes = 16 KB


Your libraries have alignments like:


LibraryAlignment foundRequired
libc++_shared.so0x00000000000d35c8❌ not 0x4000
libjniPdfium.so0x000000000001e8c0❌ not 0x4000
libmodft2.so0x00000000000b50e0❌ not 0x4000
libmodpdfium.so0x00000000004a3968❌ not 0x4000
libmodpng.so0x000000000003f450❌ not 0x4000

Not a single one has Align 0x4000, so Google Play will reject this APK when targeting API 34+ devices with 16 KB page size.




🚩 Most critical offenders​


The problematic libraries all originate from PDFium / modpdfium / modpng stack — this library set was built with older NDK toolchains that did not support 16 KB page sizes.




🧠 What this means​


This APK cannot be published on Google Play for devices with 16 KB memory pages (Samsung S24, Pixel 9, etc.) without rebuilding these libs.




🛠 How to fix it​


Rebuild every native library using:


NDK r26b or newer
and pass linker flags:



-Wl,-z,max-page-size=16384
-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON


Example for CMake:



set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,max-page-size=16384")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size=16384")


For PDFium specifically, you need a recent build — the older static libraries are not compatible.
 

MarcoRome

Expert
Licensed User
Longtime User
Hi
Attached is the library to replace the old one (essentially the arr file is purged of some libraries that Google saw as NOT compatible)
I have already submitted apps with pdfium with this library and they all passed leaving the compatibility with the devices ( 16kb )




1765469972003.png


Link:
Pdfium
 
Upvote 0
Top