我尝试使用opencv lib创建NDK项目,但出现以下错误:
Build command failed.
Error while executing process E:\SoftWare\Android\android-ndk-r19c\ndk-build.cmd with arguments {NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=C:\Users\127051\Documents\StudioProjects\StudioProjects\ImageProccessing\app\src\main\cpp\Android.mk NDK_APPLICATION_MK=C:\Users\127051\Documents\StudioProjects\StudioProjects\ImageProccessing\app\src\main\cpp\Application.mk APP_ABI=armeabi-v7a NDK_ALL_ABIS=armeabi-v7a NDK_DEBUG=1 APP_PLATFORM=android-24 NDK_OUT=C:/Users/127051/Documents/StudioProjects/StudioProjects/ImageProccessing/app/build/intermediates/ndkBuild/debug/obj NDK_LIBS_OUT=C:\Users\127051\Documents\StudioProjects\StudioProjects\ImageProccessing\app\build\intermediates\ndkBuild\debug\lib APP_CPPFLAGS+=-std=c++14 -DANDROID_STL=gnustl_static APP_SHORT_COMMANDS=false LOCAL_SHORT_COMMANDS=false -B -n}
E:\SoftWare\Android\android-ndk-r19c\build\\..\prebuilt\windows-x86_64\bin\make: invalid option -- A
E:\SoftWare\Android\android-ndk-r19c\build\\..\prebuilt\windows-x86_64\bin\make: invalid option -- N
E:\SoftWare\Android\android-ndk-r19c\build\\..\prebuilt\windows-x86_64\bin\make: invalid option -- O
Usage: make [options] [target] ...
Options:
-b, -m Ignored for compatibility.
-B, --always-make Unconditionally make all targets.
-C DIRECTORY, --directory=DIRECTORY
Change to DIRECTORY before doing anything.
-d Print lots of debugging information.
--debug[=FLAGS] Print various types of debugging information.
-e, --environment-overrides
Environment variables override makefiles.
-f FILE, --file=FILE, --makefile=FILE
Read FILE as a makefile.
-h, --help Print this message and exit.
-i, --ignore-errors Ignore errors from commands.
-I DIRECTORY, --include-dir=DIRECTORY
Search DIRECTORY for included makefiles.
-j [N], --jobs[=N] Allow N jobs at once; infinite jobs with no arg.
-k, --keep-going Keep going when some targets can't be made.
-l [N], --load-average[=N], --max-load[=N]
Don't start multiple jobs unless load is below N.
-L, --check-symlink-times Use the latest mtime between symlinks and target.
-n, --just-print, --dry-run, --recon
Don't actually run any commands; just print them.
-o FILE, --old-file=FILE, --assume-old=FILE
Consider FILE to be very old and don't remake it.
-p, --print-data-base Print make's internal database.
-q, --question Run no commands; exit status says if up to date.
-r, --no-builtin-rules Disable the built-in implicit rules.
-R, --no-builtin-variables Disable the built-in variable settings.
-s, --silent, --quiet Don't echo commands.
-S, --no-keep-going, --stop
Turns off -k.
-t, --touch Touch targets instead of remaking them.
-v, --version Print the version number of make and exit.
-w, --print-directory Print the current directory.
--no-print-directory Turn off -w, even if it was turned on implicitly.
-W FILE, --what-if=FILE, --new-file=FILE, --assume-new=FILE
Consider FILE to be infinitely new.
--warn-undefined-variables Warn when an undefined variable is referenced.
This program built for i686-w64-mingw32
Report bugs to <bug-make@gnu.org>
这是项目gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.idin.imageproccessing"
minSdkVersion 24
targetSdkVersion 28
versionCode 1
versionName "1.0"
externalNativeBuild {
ndkBuild{
arguments '-DANDROID_STL=gnustl_static'
cppFlags "-std=c++14"
}
cmake {
arguments '-DANDROID_STL=gnustl_static'
cppFlags "-std=c++14"
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
debuggable = true
jniDebuggable true
}
}
externalNativeBuild {
ndkBuild {
path 'src/main/cpp/Android.mk'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
implementation project(':openCVLibrary345')
}
这些是mk文件: Application.mk
APP_ABI := arm64-v8a
APP_CPPFLAGS := -frtti -fexceptions
APP_PLATFORM := android-24
Android.mk
LOCAL_PATH := $(call my-dir)
PROJECT_ROOT:= $(call my-dir)/../../../../..
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES:=on
OPENCV_CAMERA_MODULES:=on
include E:/OldNoteBook/SoftWare/Android/opencv-3.4.5-android-sdk/OpenCV-android-sdk/sdk/native/jni/OpenCV.mk
LOCAL_MODULE := libopencv_ndk
LOCAL_CFLAGS := -Werror -Wno-write-strings -std=c++14
LOCAL_SRC_FILES := native-lib.cpp \
CV_Main.cpp \
Native_Camera.cpp \
Image_Reader.cpp
LOCAL_LDLIBS := -llog -lmediandk -lcamera2ndk
include $(BUILD_SHARED_LIBRARY)
如何解决此错误? 如何删除这些选项?
环境详细信息:
NDK版本:r19c
主机操作系统:Windows
IDE:Android Studio 3.3.2
SDK平台工具:28.0.2
SDK工具:25.2.5
答案 0 :(得分:0)
arguments '-DANDROID_STL=gnustl_static'
这是无效的。您需要APP_STL=gnustl_static
。