

The last thing you need to do is adding the logging library to your Android.mk makefile: include $ ( CLEAR_VARS ). The log tag ( LOG_TAG) can be chosen freely. You need to implement the onClick method If you needed to see how to add a listener to an Android Button, I hope this example code is helpful. The log message is routed to Android’s logcat and has log level “info” (due to ANDROID_LOG_INFO). Here’s an example: #include #define LOG_TAG "testjni" #define ALOG(.) _android_log_print(ANDROID_LOG_INFO,LOG_TAG,_VA_ARGS_) void myMethod ( ) ĪLOG works like printf(), so you can add parameters to the log message. Unfortunately, I couldn’t get this working.įortunately, the Android NDK provides a logging API for C/C++. The easiest form of logging I can think of is using printf(). Developer can manually delete the logs using leteLogs.

Launch Android Studio and accept the defaults in the Android Studio Setup Wizard. The Android development tools provide the BuildConfig.DEBUG flag for this purpose. If you don’t have a week to get the debugging toolchain working, and if you only need some quick and temporary solution, logging may be an alternative. Install Android Studio, accepting the defaults. Android advises that a deployed application should not contain logging code. Unfortunately (this is the “I don’t like this” part), debugging Android C/C++ code is terribly difficult. I don’t like writing C/C++ code because it’s error-prone but sometimes there’s no other way. With the Android NDK Google lets us write C/C++ code for Android.
