android ndk 静态库调试 库加载成功了吗? 有执行到__android_log_write这个函数吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 是makefile文件?唉 看不懂! 我想应该没有有执行到__android_log_write这个函数 只知道Android.mk是干啥的,怎么写就不会了,汗 参考一下下面的一篇文章:http://blog.csdn.net/knock/archive/2010/04/21/5511255.aspx有点复杂,文章中提到“程序中#include "log.h"之前要定义LOG_TAG,不然就为空.”我没有尝试,你可以试一下有没有效果 这个是我写的代码,能够调用日志!最好是单独启动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;} 1.在mk文件加入:LOCAL_LDLIBS := -llog2.在cpp文件加入:#include <android/log.h>#define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, "keymatch", __VA_ARGS__)3.使用:LOGI("input params Challenge"); camera拍照水平翻转 关于发送信息加密问题! android的ListItem单击后向其它activity中sendMessage的问题 播放视频一段时间后死机 IDEA 开发Android项目测试问题 android 中大数据库 导出到手机里或者电脑上的某个文件夹中 java.io.StreamCorruptedException: Wrong format Activity 启动一个死循环线程无响应 求解啊 android 回到home下 ,点击icon不能回到退出的界面; 求助.关于调用api ANT编译时如何实现编译特定的drawable目录
__android_log_write这个函数
http://blog.csdn.net/knock/archive/2010/04/21/5511255.aspx
有点复杂,文章中提到“程序中#include "log.h"之前要定义LOG_TAG,不然就为空.”
我没有尝试,你可以试一下有没有效果
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;
}
2.在cpp文件加入:
#include <android/log.h>
#define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, "keymatch", __VA_ARGS__)3.使用:LOGI("input params Challenge");