Error using PDFNet Android SDK with PowerMock

Question:

I am trying to use PDFNet Android SDK with a Mock library called PowerMock.

However, I am getting the following error.

java.lang.ExceptionInInitializerError: Unexpected loadLibrary error. If this error persists please go to pdftron.com/kb_android_loadlibrary_error

How can I use PDFNet with a Mocking library?

Answer:

There is static initilization, and loading, of our native library, when the com.pdftron.pdf.PDFNet class is loaded, and that you need to suppress.

Try adding the following.

@SuppressStaticInitializationFor("com.pdftron.pdf.PDFNet")

Source:
https://github.com/powermock/powermock/wiki/Suppress-Unwanted-Behavior

See #4.

For people reading this, that are using other Mock frameworks, there should be a similar, or identical, feature that you can use to suppress the static initialization.