6

I have Android project (not ndk). In this project i'm linking my own native library myLib.so. I compiled my library for: armeabi-v7a and x86. So in jniLibs folder I have two folders with my lib: armeabi-v7a, x86.

When user runs my app on Samsung S6, i have next crash log:

> java.lang.UnsatisfiedLinkError:
> dalvik.system.PathClassLoader[DexPathList[[zip file
> "/data/app/com.mycompany.test-2/base.apk"],nativeLibraryDirectories=[/data/app/com.mycompany.test-2/lib/arm64,
> /vendor/lib64, /system/lib64]]]


> couldn't find "myLib.so" at java.lang.Runtime.loadLibrary(Runtime.java:366) at
> java.lang.System.loadLibrary(System.java:989)

Whats going on ? why 64 bit device not running with my lib ?

Jim
  • 8,874
  • 16
  • 68
  • 125

2 Answers2

16

If you have only x86 and armeabi-v7a libraries, your app should automatically be installed in "32-bit mode".

Are you sure you don't have another library that would include .so files inside your APK's lib/arm64-v8a folder? In that case only the libs inside this folder will get installed (without yours).

Edit: to include only x86 and armeabi-v7a libs, you can use abiFilters:

android {
    ....
    defaultConfig {
        ....
        ndk {
            abiFilters "armeabi-v7a", "x86"
        }
    }
}
ph0b
  • 14,353
  • 4
  • 43
  • 41
  • Wow, i looked inside apk, and actually I see folder arm64-v8a !! Why android generate that for me ? How can I remove it ? – Jim Jun 23 '15 at 13:32
  • compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+' I'm using this library in my project..And looks like this library put .so files in lib/arm64-v8a. How can i block that – Jim Jun 23 '15 at 13:35
  • 1
    You can do this: android { .... defaultConfig { .... ndk { abiFilters "armeabi-v7a", "x86" } } } – ph0b Jun 24 '15 at 07:33
  • Thank you so much !! Saved my time – Jim Jun 24 '15 at 16:18
  • 2
    This answer worked, but I also had to add `android.useDeprecatedNdk=true` to the `gradle.properties` file in my app's root folder. – Alan Kinnaman Feb 22 '16 at 01:25
  • In our case 64-bit library turned out to be a Realm database. So, beware of that. – Dmitry Zaytsev May 02 '16 at 13:00
-3

32-bit libraries cannot be loaded from 64-bit code. You need to compile a 64-bit version of your library or make your Java app be 32-bit.

Dan Albert
  • 10,079
  • 2
  • 36
  • 79