shared objects - How to use a pre-compiled .so file in another android app? -


i wonder why there no proper answer question, searched couple of hours no answer. so, work on team in friend wrote c library , compiled .so file (it's called ttplib.so)(assume don't have access it's c code). have use .so file in android application. don't know how load library , how use methods. have documentation of it. great if can tell me how create android.mk file too. have use dlopen?

put ttplib.so in new project's libs/armeabi or libs/armeabi-v7a folder depending compiled with.

somewhere in new app (before interacting library) add line of code

system.loadlibrary( "ttplib" ); 

now it's loaded in memory, you'll need interact using jni. you'll have go c code export jni functions:

jniexport jint jnicall java_com_example_package_myclass_methodname( jnienv* env, jobject jthis, jfloat value ) {     return 5; } 

then you'll need add classname.java in new project:

package com.example.package;  public class myclass {     private native int methodname( float value );      private void somejavamethod()     {         int = methodname( 65.33f );     } } 

that's it, in nutshell.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -