Troubleshooting
Fixes for the most common problems with NexPDF for Android - native libraries not loading, ABIs, R8, license and watermark issues, fonts, signatures, OCR and memory.
The device's ABI has no NexPDF library in the APK. The AAR ships arm64-v8a, armeabi-v7a and
x86_64 only, so:
- 32-bit x86 emulators (
x86) are not supported; use anx86_64or arm64 system image; - if you set
ndk.abiFilters, orsplits.abi, keep to those three ABIs; - check the APK in Android Studio (Build > Analyze APK):
lib/<abi>/must contain bothlibnexpdf_ffi.soandlibnexpdf_jni.so.
The JNI bridge looks up NexPdfJni methods by name, so R8 must not rename them. The AAR carries
consumer keep rules for NexPdfJni, NexPdfLicense, NexPdfReaderActivity and NexPdfUIConfig.
If you repackage its classes (for example into another AAR), those rules are lost; add them to your
own proguard-rules.pro:
-keep class com.nexdevit.nexpdf.NexPdfJni { native <methods>; *; }
-keep class com.nexdevit.nexpdf.NexPdfLicense { *; }
-keep class com.nexdevit.nexpdf.ui.NexPdfReaderActivity { *; }
-keep class com.nexdevit.nexpdf.ui.NexPdfUIConfig { *; }Local unit tests (src/test) run on your computer's JVM, which cannot load the Android .so
files in the AAR.
Run tests that call NexPDF as instrumented tests (src/androidTest) on a device or emulator.
Check JSONObject(NexPdfLicense.status()).optString("state") in the process that renders:
unlicensed:NexPdfLicense.initializewas never called, or it returned a negative code. Call it inApplication.onCreate()so it also runs in every extra process your app starts.trial: trial keys always keep the "NexPDF • Trial" watermark.licensed: commercial keys render without a watermark. If you still see one, the bitmap comes from a cache of an earlier render.
Android keys are bound to the platform android and the package name read from the Context
(applicationId). A -7 usually means a build variant changed the package name, for example an
applicationIdSuffix of .debug. Ask for a key for that id, or drop the suffix. You can change the
platform and app id in the dashboard and download a re-signed key.
NexPdfLicense.initialize(context) found no key: neither the manifest meta-data
com.nexdevit.nexpdf.license_key nor assets/nexpdf_license.xml. Check the file is in
app/src/main/assets/ (not res/), or pass the key with initialize(context, key).
NexPdfReaderActivity calls NexPdfLicense.initialize(this) itself when it starts, which reads
the manifest meta-data or assets/nexpdf_license.xml. If your app passes the key in code only, that
call finds nothing and the reader shows the message, while the key your app activated stays active.
Put the key in the assets or the manifest as well to avoid the message.
The device's clock is earlier than the key's issue date. Fix the date and time and activate again.
Your plan does not include that module. See Modules and tiers for which
plan unlocks it, and check the key's modules to hide the feature.
NexPdfDocument.openBytes converts EPUB, FictionBook, XPS/OpenXPS and CBZ files since 1.1, and so
does the reader. With 1.0.x, update to 1.1. If a book still fails, check that the key includes the
conversion module, and try NexPdfDocument.openEbook(bytes) to get the e-book converter's own
error. See Opening and saving.
The PDF uses a standard font (Helvetica, Times, Courier) without embedding it. The engine bundles
the Liberation fonts as substitutes; NexPdfJni.hasBundledFonts() tells you whether your build
has them, and NexPdfJni.registerStandardFont(fontBytes) adds them at run time.
The page is a scanned image with no text layer. Run OCR first; it adds an invisible text layer that extraction and search then read.
With "engine": "auto", Tesseract is used only when the tesseract program can be run and has
data for every requested language. Android has no such program, so OCR uses a loaded neural model
when one reads the requested languages, and otherwise the built-in engine, which reads Latin-script
text. See OCR.
The built-in engine reads Latin-script text only. Load a detection model and a recognition model
for the script with NexPdfJni.ocrLoadModel before calling ocrJson, and pass matching
languages. NexPdfJni.ocrModelsJson() lists what is loaded; the report's engine says
neural (<name>) when a model was used. Keep .onnx files uncompressed in the APK
(noCompress). See OCR.
The file is a dynamic XFA form, which most viewers no longer lay out. Convert it with
xfaToAcroform() or xfaFlatten(); see XFA forms. Scripts in
the form (FormCalc, JavaScript) are not run.
The document was converted as far as possible, but some PDF/A rules still fail;
NexPdfJni.lastError() lists their clauses. Run validatePdfaJson(level) to see each failure with
its page and object. See PDF/A and PDF/UA validation.
tsa_url, ltv, addLtv and the document timestamp calls contact the timestamp authority and the OCSP and CRL servers named in
the certificates. The AAR does not request the INTERNET permission; add it to your app's manifest:
<uses-permission android:name="android.permission.INTERNET" />Signing returns the complete signed file as a byte[]. Write those bytes unchanged. Calling
saveBytes() on the document afterwards rewrites the file and invalidates the signature. See
Signatures.
Render at the size you show: a page bitmap takes width x height x 4 bytes, so an A4 page rendered
at 216 dpi (about 1786 x 2526 pixels) is about 18 MB. Keep only the pages on screen, call
NexPdfJni.trimMemory(handle) from onTrimMemory, and close documents you no longer need. See
Platform notes.
Every NexPDF call is synchronous and runs on the calling thread. Move opening, rendering, OCR, signing and conversion off the main thread. See Platform notes.
Still stuck? Check Error handling for the meaning of each error, or the general FAQ.