Java – NDK does not have that file or directory

NDK does not have that file or directory… here is a solution to the problem.

NDK does not have that file or directory

Ok, so I want to compile what I wrote in Github I had never tried to make a low-level language application before this was my first attempt, so although I first compiled an already running project and analyzed it, Android studio asked me to download ND to set it up after I developed this error: ‘Error :Gradle: Task ‘:app:compileDebugNdk’ execution failed.

com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/Applications/adt-bundle-mac-x86_64-20140702/ndk/ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/********************/********************/AndroidStudioProjects/ android_packages_apps_FMRadio-cm-12.1/app/build/intermediates/ndk/debug/Android.mk APP_PLATFORM=android-21 NDK_OUT=/********************/********************/AndroidStudioProjects/android_packages_apps_FMRadio-cm-12.1/app/build/intermediates/ndk/debug/obj NDK_LIBS_OUT=/********************/********************/AndroidStudioProjects/android_packages_apps_FMRadio-cm-12.1/app/build/intermediates/ndk/debug/lib APP_ABI=all
Error Code:
2
Output:
In file included from /********************/********************/********************/android_packages_apps_FMRadio-cm-12.1/app/src/main/jni/fmr/common.cpp:17:0:
/********************/********************/AndroidStudioProjects/android_packages_apps_FMRadio-cm-12.1/app/src/main/jni/fmr/fmr.h:21:23: fatal error: utils/Log.h: No such file or directory
#include
^
compilation terminated.
make: *** [/********************/********************/AndroidStudioProjects/android_packages_apps_FMRadio-cm-12. 1/app/build/intermediates/ndk/debug/obj/local/arm64-v8a/objs/app//********************/********************/AndroidStudioProjects/android_packages_apps_ FMRadio-cm-12.1/app/src/main/jni/fmr/common.o] Error 1`

Solution

It looks like the project is not intended to be built as a standalone application, but as part of a full firmware build (part of the Cyanogen mod). The error basically means that the file utils/log.h cannot be found. The file is not part of the project, nor is it part of the Android NDK.

To avoid having to set up a full environment that you most likely won’t use, I recommend choosing another project to start with.

If you really want to stick with this project, I recommend you make some changes to the file jni/fmr/fmr.h first.

1: Change <utils/log.h > into <android/log.h>

When you recompile, it may prompt that all ALOG* definitions cannot be found.

2: Replace this part:

#undef FM_LIB_USE_XLOG

#ifdef FM_LIB_USE_XLOG
#include <cutils/xlog.h>
#undef LOGV
#define LOGV(...) XLOGV(__VA_ARGS__)
#undef LOGD
#define LOGD(...) XLOGD(__VA_ARGS__)
#undef LOGI
#define LOGI(...) XLOGI(__VA_ARGS__)
#undef LOGW
#define LOGW(...) XLOGW(__VA_ARGS__)
#undef LOGE
#define LOGE(...) XLOGE(__VA_ARGS__)
#else
#undef LOGV
#define LOGV(...) ALOGV(__VA_ARGS__)
#undef LOGD
#define LOGD(...) ALOGD(__VA_ARGS__)
#undef LOGI
#define LOGI(...) ALOGI(__VA_ARGS__)
#undef LOGW
#define LOGW(...) ALOGW(__VA_ARGS__)
#undef LOGE
#define LOGE(...) ALOGE(__VA_ARGS__)
#endif

This part:

#define LOGV(...)  __android_log_print(ANDROID_LOG_VERBOSE,LOG_TAG,__VA_ARGS__)
#define LOGD(...)  __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__)
#define LOGI(...)  __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGW(...)  __android_log_print(ANDROID_LOG_WARN,LOG_TAG,__VA_ARGS__)
#define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)

This should get you started.

Edit:

I

think I found the referenced utils/log.h (but probably not from the correct project):
https://github.com/CyanogenMod/android_frameworks_ex/blob/cm-12.0/framesequence/jni/utils/log.h

Related Problems and Solutions