I am trying to log some info from my native code into logcat but I can't seem to get it working. I have searched all over stackoverflow (and other websites).
In my native code I have #include <android/log.h>. It fully compiles with no errors. If I don't use the logging at all my native code runs in android.
my Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := mylib-prebuilt
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/mylib.so
LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)/$(TARGET_ARCH_ABI)
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := gmp-prebuilt
LOCAL_SRC_FILES := $(TARGET_ARCH_ABI)/libgmp.so
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY)
The error I get:
java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "__android_log_write" referenced by <package>
Lastly, the log I use looks like this:
__android_log_write(ANDROID_LOG_ERROR, "Native tag", "Native text");
Does anybody know what is going wrong?
Try -llog in your link step. You need the logging library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With