[Android] NDK 常見編譯問題整理
1、錯誤:Are you sure your NDK_MODULE_PATH variable is properly defined ?
編譯 NDK 專案時,如果遇到以下類型的問題:
Android NDK: jni/clapack/SRC/Android.mk: Cannot find module with tag 'mymodule' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?
Android NDK: The following directories were searched:
Android NDK:
jni/Android.mk:56: *** Android NDK: Aborting. . Stop.
其中一種解決方法是在 Eclipse 中,在你的專案上按一下滑鼠右鍵 > Properties,新增下列環境變數,並將其值設為你的 module 目錄:

另一種方法是在 Android.mk 中將 Module 的目錄加入 PATH:
找到:
$(call import-module, your module)
在兩者之間加入你的 module 路徑,我這裡設為目前的專案路徑:
$(call import-add-path,my_relative_path)
2、錯誤:Cannot find module with tag ‘cpufeatures’ in import path
編譯 NDK 專案時,如果遇到以下類型的問題:
Cannot find module with tag 'cpufeatures' in import path
這可能是因為你的 Android.mk 沒有正確匯入(可能是舊版與新版 ndk api 的差異所致)。找到:
$(call import-module,cpufeatures)
改成:
$(call import-module,android/cpufeatures)
3、錯誤:Symbol ‘vector’ could not be resolved
編譯 NDK 專案時,如果遇到以下類型的問題:
Symbol 'vector' could not be resolved
若要解決這個問題,請依照下列步驟設定:
1)在專案目錄上按一下滑鼠右鍵,選擇 Properties -> C/C++ General -> Code Analysis
點選:Use project settings
接著取消勾選 Syntax and semantic errors。如下圖所示:

2)選擇 Path and symbols 選單,在 include 分頁中點選 Add 按鈕,加入 $ndk_root\platforms\android-*\arch-arm\usr\include 路徑。請依照實際安裝的 ndk 路徑和版本調整。並勾選 Add to all languages,如下圖所示:

儲存設定即可。