undefined reference to `__android_log_print'

You need to add

LOCAL_LDLIBS := -llog

to Android.mk


Try the following in your Android.mk file:

LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog

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"
        }
    }
}

For Android Studio 2.2 and tools.build:gradle:2.2.0 using CMake add or edit row in CMakeLists.txt:

target_link_libraries(<your_library_name> 
                      android 
                      log)

Thats connecting log library to yours.


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'])
}