Parthraj
Parthraj

Reputation: 573

how to include .so file in Android

I am customizing the Gingerbread source code. One of my app needs .so file to be included in it. But I am not getting success in it. Please help me. I have go through some answers here, but it doesn't work for me.

Upvotes: 2

Views: 8241

Answers (3)

rana
rana

Reputation: 1862

To include .so files as a library follow this steps.

  1. create a folder inside . lets call it libs. Place .so inside this folder

  2. Right click on project -> click on Java Build path -> click on Source tab -> click on Add .now point this libs or include any directory which stores .so files.
    click Order and export tab on the same window and make sure it is checked.

Now you can access this .so using JNI interface with system.load() calls as java files. For better interaction always declare all JNI interface inside a Java class and include it inside current project

Upvotes: 0

neeraj
neeraj

Reputation: 740

make the directory structure like in this way .

make directory names as "libs" .

and now make subdirectory named as "armeabi"

and then copy your .so file in "armeabi" filder .

like . libs/armeabi/YOUR_SO_FILE .

and then write code in you program .

 System.loadLibrary("NAME_OF_YOUR_FILE");

Upvotes: 5

Ovidiu Latcu
Ovidiu Latcu

Reputation: 72321

You will have to place your .so file inside the libs/armeabi folder of your Project. If this folders do not exist you will need create them. If your .so file is not created, and you want to create it and for more information you could look at What is the NDK?.

If you want to include the .so file in the customized source code (which I do not recommend since this will mean that your app will work/can use the shared library only on that customized OS) I think you will need to place the .so file inside the lib/ folder.

Upvotes: 0

Related Questions