Android: Getting ExceptionInInitializerError after migrating from Eclipse to Android Studio?

Q: Could not load PDFNetC/getting java.lang.ExceptionInInitializerError/getting java.lang.UnsatisfiedLinkError after migrating from Eclipse to Android Studio?

  1. place the native libraries under “AppModule/src/main/jniLibs” directory
  2. if you want to keep the folder structure to be compatible with Eclipse, then specify in build.gradle the location of jni folder:

android.applicationVariants.all { variant →
// Since we are keeping the folder structure to be compatible with Eclipse,
// we need to set the folder where the native libs are stored
variant.packageApplication.jniFolders = [new File(projectDir, “libs”)] as Set
}

See PDFViewCtrlDemo project for example.
A: In Android Studio, there are two ways to include the PDFNetC native library: