Ryan Chrome
Ryan Chrome

Reputation: 11

How do you add a native library (.so) to android studio?

I am currently getting the following error:

java.lang.UnsatisfiedLinkError: nativeLibraryDirectories=[/data/app/com.example.ryane.jzy-1/lib/arm, /vendor/lib, /system/lib] couldn't find "libgluegen-rt.so"

While performing the following line of code

System.loadLibrary("gluegen-rt");

I've included the following in my build.gradle

sourceSets {
    main {
        jniLibs.srcDirs = ["src/main/jniLibs", "$buildDir/native-libs"]
    }
}

And have placed my libgluegen.so within src/main/jniLibs. According to the error it seems as if it isn't looking in the directory I specified. Are there steps that I'm missing?

Upvotes: 1

Views: 5565

Answers (1)

Rust Fisher
Rust Fisher

Reputation: 341

Hmm... Actually I want to see your .so path...
And for example, in my build.gradle jniLibs.srcDirs = ['src/main/libs'] .

The path of .so is MyProj\app\src\main\libs\armeabi-v7a\libSmartAlgorithm.so .

libs/TARGET_ARCH_ABI

arm64-v8a
armeabi
armeabi-v7a
mips
mips64
x86
x86_64

Upvotes: 1

Related Questions