Reputation: 103
This is the .cpp file and the code is
JNIEXPORT jint JNICALL Java_com_example_compute_MainActivity_AddNumbers(JNIEnv *env, jobject obj, jint v1, jint v2)
{
_android_log_print(ANDROID_LOG_VERBOSE, "VaxVoIP", "The value of 1 + 1 is %d", 1+1);
return -1;
//return (v1 + v2);
}
This is the Android.mk file
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
Here we give our module name and source file(s)
LOCAL_MODULE := add
LOCAL_LDLIBS := -llog
LOCAL_SRC_FILES := add.cpp\
add.h\
include $(BUILD_SHARED_LIBRARY)
And the other error that I'm trying to solve is while making the .so file
_android_log_print(ANDROID_LOG_VERBOSE, "VaxVoIP", "The value of 1 + 1 is %d", 1+1);
was not declared in this scope
Upvotes: 3
Views: 4950
Reputation: 40
It's probably because of the buffer. Put \n
at the end of the string.
__android_log_print(ANDROID_LOG_VERBOSE, "VaxVoIP", "The value of 1 + 1 is %d\n", 1+1);
Also don't forget to put double underscores rather than one single underscore.
Upvotes: 0
Reputation: 4415
John is right about it. I just got it resolved by including #include <android/log.h>
and also add LOCAL_LDLIBS += -llog -ldl -landroid in android.mk file
Upvotes: 1
Reputation: 235
If that's the whole .cpp file, you're going to need to #include something that defines _android_log_print.
Upvotes: 0