title: Android NDK - multlib support using gradle
body: <p>My question is directed towards native Android development for 64bit Android systems.</p>
  
  <p>I am looking for a way to configure the support of 32bit compiled native libraries at a 64bit Android system using the gradle build system. The libraries the application should use are only available as 32bit build. It would be very time consuming and error prone to port these libraries to 64bit.</p>
  
  <p>Hence, I want to configure gradle to deploy these prebuilt 32bit binaries and to use a 32bit version of the Android application as well.</p>
  
  <p>The current configuration leads to the following error:</p>
  
  <pre><code> E/AndroidRuntime﹕ FATAL EXCEPTION: main
      Process: &lt;application_name&gt;, PID: 2170
      java.lang.UnsatisfiedLinkError: 
  dalvik.system.PathClassLoader
  [DexPathList[[zip file "/data/app/&lt;application_name&gt;/base.apk"],
  nativeLibraryDirectories=[/vendor/lib64, /system/lib64]]] 
  enter code here`couldn't find "libmynativelibrary.so"
      at java.lang.Runtime.loadLibrary(Runtime.java:366)
  </code></pre>
  
  <p>It seems as though the <code>PathClassLoader</code> looks in the wrong directories. I checked the provided apk file and it is lacking the libraries. There is no <code>lib</code> folder inside the apk. The build system does not seam to include the 32bit libraries.
  Since there is only one prebuild version for <code>armv7</code> these libraries are in <code>app/src/main/jnilibs</code> folder. </p>
  
  <p>I have to add that this setup works perfectly for any 32bit Android system. I tried it with the emulator and a physical device before.</p>
  
  <p>How should one activate the multiarch 32/64bit support using gradle? Or how is it possible to deploy a 32bit application to a 64bit Android system using Android Studio/gradle?</p>
  
  <p>I searched the web and found one link concerning the topic, but it is referring to the older build system: <a href="https://source.android.com/source/64-bit-builds.html" rel="nofollow">https://source.android.com/source/64-bit-builds.html</a>. I do not know how to adopt the description to gradle.</p>
  
  <p>I am using Android Studio (Build: 141.1989493, June 6, 2015).
  The <code>project/build.gradle</code> is untouched. The <code>app/build.gradle</code> file looks like this:</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 22
      buildToolsVersion "22.0.1"
  
      defaultConfig {
          applicationId "&lt;application_name&gt;"
          minSdkVersion 1
          targetSdkVersion 22
          versionCode 1
          versionName "1.0"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'),
                                                   'proguard-rules.pro'
          }
          debug {
              debuggable true
          }
      }
  
      productFlavors {
          armv7 {
              ndk {
                  abiFilter "armeabi-v7a"
              }
          }
          fat
      }
  }
  
  dependencies {
      compile fileTree(dir: 'libs', include: ['*.jar'])
  }
  </code></pre>