库加载成功了吗? 有执行到
__android_log_write这个函数吗?

解决方案 »

  1.   

    是makefile文件?唉 看不懂!
      

  2.   

    我想应该没有有执行到
    __android_log_write这个函数
      

  3.   

    只知道Android.mk是干啥的,怎么写就不会了,汗
      

  4.   

    参考一下下面的一篇文章:
    http://blog.csdn.net/knock/archive/2010/04/21/5511255.aspx
    有点复杂,文章中提到“程序中#include "log.h"之前要定义LOG_TAG,不然就为空.
    我没有尝试,你可以试一下有没有效果
      

  5.   

    这个是我写的代码,能够调用日志!最好是单独启动DDMS然后通过其查看日志
    Libtest.so 文件,声明java调用接口,动态加载so
    #include <string.h>
    #include <jni.h>
    #include <dlfcn.h>                              //加载动态库头文件
    #include <android/log.h>                //日志打印头文件
    #include <stdlib.h>#define  LOG_TAG    "libgl2jni"
    #define  LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
    #define  LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
     //extern int getinformation();
    jint Java_com_example_test_test01_getinformation(JNIEnv* env,jobject thiz)
    {
    void*  filehandle = dlopen("/data/data/com.example.test/lib/libtutorial.so", RTLD_LAZY );
    int ll = -1;
    if(filehandle)
    {
        LOGI("open so success!");
    int( * getinformation ) () =dlsym(filehandle, "getinformation");
    if( getinformation )
    {
    LOGI("call function getinformation OK!");
    ll = getinformation();
    }
    else
    {
    ll = -3;
    LOGE("call function getinformation! ERROR!");
    }
    LOGI("return value=%d",ll);
    dlclose(filehandle);
    filehandle=0;
    }
    else
    {
    ll = -2;
    LOGE("open so ERROR!");
    }
        return ll;
    }
      

  6.   

    1.在mk文件加入:LOCAL_LDLIBS    := -llog
    2.在cpp文件加入:
    #include <android/log.h>
    #define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, "keymatch", __VA_ARGS__)3.使用:LOGI("input params Challenge");