PdfiumAndroid - SDK 35 / Android 15 Compatible
This repository is a fork of meganz/PdfiumAndroid, which itself is based on barteksc/PdfiumAndroid.
What's New in This Fork
This fork is updated to SDK 35 / NDK 28 and delivers a working AAR compatible with Android 15 (16KB page size support).
Version 2.0.1 - Significant updates to the build layer and compatibility improvements warrant a major version bump from the original 1.9.0.
Key Updates:
- Android SDK 35 and NDK 28 compatibility
- Android Gradle Plugin 8.9.2 support
- Java 17 requirement (configured via
gradle.properties) - BuildConfig generation fixed for library modules
- Native library packaging corrected in AAR
- 16KB page size support for Android 15
- Windows Git Bash compatible build script
Requirements
- Java 17+ (required for AGP 8.9.2+)
- Android NDK 28.2.13676358
- Git Bash (for Windows users)
- Ninja build tool - https://github.com/ninja-build/ninja/releases
Building the Library
1. Build Native Libraries
Remark: you might need to update the NDK_ROOT environment variable in the build.sh script to point to your NDK (preferrably v28+)
# Run the build script to compile native libraries ./build.sh # Optional: Build specific components ./build.sh --build-png --build-freetype
2. Build AAR
Remark: you might need to update the 'javaHome' environment variable in the gradle.properties file to point to your Java 17 installation
# Build debug AAR ./gradlew assembleDebug # Build release AAR ./gradlew assembleRelease # Output: build/outputs/aar/PdfiumAndroid-2.0.1-release.aar
Using in Your Project
Method 1: Local AAR
- Copy
PdfiumAndroid-2.0.1-release.aarto your app'slibs/folder - Add to your app's
build.gradle:
dependencies {
implementation files('libs/PdfiumAndroid-2.0.1-release.aar')
implementation 'androidx.core:core:1.16.0'
}Method 2: JitPack (if published)
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.yourusername:PdfiumAndroid:v2.0.1'
}Usage Example
import com.shockwave.pdfium.PdfiumCore; import com.shockwave.pdfium.PdfDocument; // Initialize PdfiumCore pdfiumCore = new PdfiumCore(context); // Open PDF PdfDocument pdfDocument = pdfiumCore.newDocument(parcelFileDescriptor); // Use the library...
Changes Made
Build System Updates
- Updated
build.gradlefor AGP 8.9.2 compatibility - Added
buildFeatures { buildConfig = true } - Added
buildConfigFieldforVERSION_NAME - Fixed
jniLibs.srcDirpath for native libraries - Configured Java 17 in
gradle.properties
Native Library Fixes
- Updated
build.shto use ninja (for windows) - Updated
build.shto copylibjniPdfium.soto correct location - Fixed AAR packaging to include all required
.sofiles - Ensured compatibility with NDK 28
Android 15 Compatibility
- Added 16KB page size support via
ANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON - Updated manifest and build configuration
Original Credits
- Original work: barteksc/PdfiumAndroid
- 16KB page size foundation: meganz/PdfiumAndroid
- Upgrade to PDFium 133.0.6927.0
- Add a
CMakeLists.txtfor building PdfiumAndroid.sofile. - Update libpng v1.6.44 and libfreetype2 v2.10.0 binaries for building PdfiumAndroid library.
License
Same as original project - check the LICENSE file.