title: How to setup Android library module with productflavors and jni
body: <p>I'm trying to include mupdf as an android library module with precompiled .so binaries into my project.</p>
  
  <p>I have an application module which includes my library module like so.</p>
  
  <pre><code>dependencies {
     compile project(':mupdf')
  }
  </code></pre>
  
  <p>In my mupdf library module I have my compiled binaries like so.</p>
  
  <pre><code>mupdf
  - jniLibs
    - arm64-v8a
      libmupdf.so
    - armeabi
      libmupdf.so
    - armeabi-v7a
      libmupdf.so
    - x86
      libmupdf.so
    - x86_64
      libmupdf.so
  </code></pre>
  
  <p>My build.gradle for the mupdf library project:</p>
  
  <pre><code>apply plugin: 'com.android.library'
  apply plugin: 'kotlin-android'
  
  android {
      compileSdkVersion 23
      buildToolsVersion "23.0.1"
  
      defaultConfig {
          minSdkVersion 15
          targetSdkVersion 23
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
      publishNonDefault true
      productFlavors {
          x86 {
              ndk {
                  abiFilter "x86"
              }
          }
          x64 {
              ndk {
                  abiFilter "x86_64"
              }
          }
          arm {
              ndk {
                  abiFilter "armeabi"
              }
          }
          arm_v7a {
              ndk {
                  abiFilter "armeabi-v7a"
              }
          }
          arm64_v8a {
              ndk {
                  abiFilter "arm64-v8a"
              }
          }
          fat
      }
  }
  dependencies{
      compile project(':core')
  }
  </code></pre>
  
  <p>The problem is soon as I add the product flavors my app doesn't compile because it doesn't find any of the java files from the mupdf module.
  If I delete the product flavors part from the gradle file it compiles. But it crashes at runtime because it can't resolve/load the libmupdf library.</p>