hold in “Trying to load lib” and no return for ever

夙愿已清 提交于 2020-01-14 12:54:30

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!