Uday Makam
Lurker
I want to include two shared libraries liba.so and libb.so into my android application. Where function of libb.so is called from function in liba.so.
I have a Java class which calls native JNI Function as,
package com.test.myapplication;
public class MainActivity extends AppCompatActivity {
static{
System.loadLibrary(a);
System.loadLibrary(b);
}
public native void testSample();
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
testSample();
}
}
My JNI file is
#include"a.h"
extern "C" void JNICALL Java_com_test_myapplication_MainActivity_testSample( JNIEnv* env, jobject thiz) {
a_foo();
}
a.cpp file which is part of my library liba.so is
#include"b.h"
void a_foo()
{
/* ..... code .....*/
b_foo();
/* ..... code .....*/
}
My b.cpp which is part of libb.so is
void b_foo()
{
/* ..... code .....*/
}
I want to include liba.so and libb.so as librares and not as source into my application. Both the libraries are built using android-ndk independently.
Line System.loadLibrary(a); gives a runtime exception
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "b_foo" referenced by "/data/app/com.test.myapplication-yyA38UEBmsXvaqOY-hm_HQ==/lib/arm64/liba.so" when loading
I have a Java class which calls native JNI Function as,
package com.test.myapplication;
public class MainActivity extends AppCompatActivity {
static{
System.loadLibrary(a);
System.loadLibrary(b);
}
public native void testSample();
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
testSample();
}
}
My JNI file is
#include"a.h"
extern "C" void JNICALL Java_com_test_myapplication_MainActivity_testSample( JNIEnv* env, jobject thiz) {
a_foo();
}
a.cpp file which is part of my library liba.so is
#include"b.h"
void a_foo()
{
/* ..... code .....*/
b_foo();
/* ..... code .....*/
}
My b.cpp which is part of libb.so is
void b_foo()
{
/* ..... code .....*/
}
I want to include liba.so and libb.so as librares and not as source into my application. Both the libraries are built using android-ndk independently.
Line System.loadLibrary(a); gives a runtime exception
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "b_foo" referenced by "/data/app/com.test.myapplication-yyA38UEBmsXvaqOY-hm_HQ==/lib/arm64/liba.so" when loading
Last edited: