库加载成功了吗? 有执行到
__android_log_write这个函数吗?
__android_log_write这个函数吗?
解决方案 »
- 使用微云 想实现一个涂抹图片的功能,类似擦玻璃的效果
- NDK 的Program received signal SIGILL, Illegal instruction 错误
- ListView 实现动态更新以后 子项排列书序混乱
- ListView失去focus后 如何仍然高亮?
- android OPENCORE怎么调用底层MFC硬解码?
- 图片进行缩放遇到的问题
- 入手什么款式的Android机比较好呢?
- Android
- Phonegap 安装失败,无法创建Android
- adt of android使用C++//俩点消息与一点消息的区别?
- 求助.关于调用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");