To log stuff and see it in the logcat from Android, I have a simple class for that:
#ifndef LOG_H_
#define LOG_H_
#include <android/log.h>
#define LOGD(LOG_TAG, ...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGI(LOG_TAG, ...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGV(LOG_TAG, ...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
#define LOGW(LOG_TAG, ...) __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
#define LOGE(LOG_TAG, ...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
#endif /* LOG_H_ */
You can use it this way:
LOGI("YourClassTag","let's print some stuff: %i, %s", 4, "I'm a string");
To get more info for some crashes, you may try to enable JNICheck with adb:
If you have a regular device, you can use the following command:
adb shell setprop debug.checkjni 1
This won’t affect already-running apps, but any app launched from that
point on will have CheckJNI enabled. (Change the property to any other
value or simply rebooting will disable CheckJNI again.) In this case,
you’ll see something like this in your logcat output the next time an
app starts:
D Late-enabling CheckJNI