Hold "Try loading lib" and don't come back forever

I have an old application written with C ++, I try to port it to android and debug it using eclipse, but the project stops with an error message:

10-03 12: 21: 55.344: D / dalvikvm (15262): attempt to load lib / data / data / com.android.test / lib / libtest.so 0x40effa48

The application simply stops without displaying any other message. I do not know how to do that.

+4
source share
2 answers

I have the same problem but it is caused by this error

So just remove NDK_TOOLCHAIN_VERSION = 4.7 from your application. I only have it on Android 2.2 with android-ndk-r8e

+2
source

You need to add the following function to the library:

 #include <jni.h> jint JNI_OnLoad( JavaVM* vm, void* reserved ) { JNIEnv* jEnv = NULL; if ( JNI_OK != ( *vm )->GetEnv( vm, (void**)&jEnv, JNI_VERSION_1_4 ) ){ return -1; } return JNI_VERSION_1_4; 

}
updated: lack of JNI_OnLoad () is not a problem ...
You wrote in a comment that you have many global initiators - consider such global initializations in JNI_OnLoad ()

Signature:

 /* * Class: com_android_test_testLib * Method: init * Signature: (II)V */ JNIEXPORT void JNICALL Java_com_android_test_testLib_init (JNIEnv *, jclass, jint, jint); /* * Class: com_android_test_testLib * Method: uninit * Signature: ()V */ JNIEXPORT void JNICALL Java_com_android_test_testLib_uninit (JNIEnv *, jclass); /* * Class: com_android_test_testLib * Method: touch * Signature: (IIII)V */ JNIEXPORT void JNICALL Java_com_android_test_testLib_touch (JNIEnv *, jclass, jint, jint, jint, jint); /* * Class: com_android_test_testLib * Method: update * Signature: ()V */ JNIEXPORT void JNICALL Java_com_android_test_testLib_update (JNIEnv *, jclass); 
0
source

Source: https://habr.com/ru/post/1437508/


All Articles