问题
I have a old app written by C++, I am trying to port it to android
, and debug it with eclipse, but the project is stopping with an error message :
10-03 12:21:55.344: D/dalvikvm(15262): Trying to load lib /data/data/com.android.test/lib/libtest.so 0x40effa48
The application just stops without giving any other message. I don't know how to do continue.
回答1:
I have the same problem but it is caused by this bug
So simply remove NDK_TOOLCHAIN_VERSION=4.7 from your Application.mk i have this only on Android 2.2 with android-ndk-r8e
回答2:
You have to add the following function to you 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: absence of JNI_OnLoad() is not a problem...
You have written in comment that You have lots of global initers - consider do such global initializations in JNI_OnLoad()
Signatures:
/*
* 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);
来源:https://stackoverflow.com/questions/12701940/hold-in-trying-to-load-lib-and-no-return-for-ever