What is wrong with my make file?
Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := foo
LOCAL_SRC_FILES := foo.c
LOCAL
TO build with Android.bp, follow the below solution:
In this -android_log_print is defined in NDK, so for this, there is already a library is available. Use "liblog" library using shared_libs tag, take reference of the below code:
target: {
android: {
cppflags: [
"-g",
"-DUSE_LIBLOG",
],
shared_libs: ["liblog"], // can use other dependency if required.
},
darwin: {
enabled: false,
},
},
You need to add
LOCAL_LDLIBS := -llog
to Android.mk
If you use Android Studio and gradle, it ignores Android.mk. Add this to your build.gradle file:
android {
defaultConfig {
ndk {
moduleName "your_module_name"
ldLibs "log"
}
}
}
If you upgrade to Android Studio 2.1, above answers do not work, need use ldLibs.add() to load the lib as below:
android.ndk {
moduleName = "[the_module_name]"
ldLibs.addAll(['android', 'log'])
}
In lieu with
If using the new Gradle NDK integration in Android Studio 1.3, you need to add ldLibs = ["android", "log"] to your android.ndk options – Stephen Kaiser Sep 24 at 4:20
use ldLibs.addAll(["android", "log"])
for the experimental plugin
Add
LOCAL_SHARED_LIBRARIES:= \
libbinder \
liblog \
to Android.mk