Issue
I am using latest version of ndk (18.1). Whenever I try to compile my code it shows me Execution failed for task ':app:ndkBuild'
I tried 2 different versions of ndk (18.1) and (14.1), Both shows almost same error while the only difference is that;
- ndk (18.1) shows Exit Value 2
- ndk (14.1) shows Exit Value -1
jni Path:
Build.Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.fyp.major.fyp1"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
sourceSets.main {
jni.srcDirs = [] //disable automatic ndk-build call
}
task ndkBuild(type: Exec, description: 'Compile JNI source via NDK') {
commandLine "C:/Users/MaJoR/AppData/Local/Android/Sdk/ndk-bundle/ndk-build.cmd",
'NDK_PROJECT_PATH=build/intermediates/ndk',
'NDK_LIBS_OUT=src/main/jniLibs',
'APP_BUILD_SCRIPT=src/main/jni/Android.mk',
'NDK_APPLICATION_MK=src/main/jni/Application.mk'
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation project(':openCVLibrary344')
}
ANDROID.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#opencv
OPENCVROOT:= C:\OpenCV-3.4.0-android-sdk
OPENCV_CAMERA_MODULES:=on
OPENCV_INSTALL_MODULES:=on
OPENCV_LIB_TYPE:=SHARED
include ${OPENCVROOT}/sdk/native/jni/OpenCV.mk
LOCAL_SRC_FILES := com_fyp_major_fyp1_OpencvClass.cpp
LOCAL_LDLIBS += -llog
LOCAL_MODULE := MyLibs
include $(BUILD_SHARED_LIBRARY)
APPLICATION.mk
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-16
OUTPUT Error while using ndk 18.1
OUTPUT Error while using ndk 14.1
Any Solution for these Errors?
Solution
NDK r18 has dropped gnustl, so you must rebuild OpenCV for libc++.
As for NDK r14.1, there is too little info to explain the failure. Note that the screenshot mentions that ndk-stack.cmd and not ndk-build.cmd was run there. Could it be a typo when you switched to the older NDK?
Answered By - Alex Cohn
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.