我正在尝试在Android中编译.so
个文件,第一个问题是当我直接使用gradle
它运行完美但没有生成.so
文件时,所以我求助于调用{{ 1}}我自己,我对我的ndk
文件进行了一些更改,现在它看起来像我的`:
gradle.build
}
当我编译我的代码时,它只是给我一个错误,说apply plugin: 'com.android.application'
import org.apache.tools.ant.taskdefs.condition.Os
android {
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "nemo.lungu.receiptor"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled false
ndk
{
moduleName "Scanner"
stl "stlport_shared"
}
}
sourceSets.main {
jniLibs.srcDir 'src/main/libs' //set .so files location to libs
jni.srcDirs = [] //disable automatic ndk-build call
}
// call regular ndk-build(.cmd) script from app directory
task ndkBuild(type: Exec) {
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
commandLine 'ndk-build.cmd', '-C', file('src/main').absolutePath
} else {
commandLine 'ndk-build', '-C', file('src/main').absolutePath
}
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn ndkBuild
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
遇到错误所以我采用方法3;手动编译ndk
文件,我的.so
文件如下所示:
Android.mk
和LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES:=on
include .../sdk/native/jni/OpenCV.mk
LOCAL_MODULE := Scanner
LOCAL_SRC_FILES := scan.cpp
LOCAL_LDLIBS += -lm -llog -landroid
LOCAL_LDFLAGS += -ljnigraphics
include $(BUILD_SHARED_LIBRARY)
看起来像:
Application.mk
我的新错误现在无法找到APP_STL := stlport_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-15
,我正在从cmd运行ndk,如下所示
sdk/native/jni/OpenCV.mk
,如果我的项目在我的C目录的根目录中为ndk-build NDK_PROJECT_PATH=full/path/to/project APP_BUILD_SCRIPT=full/path/to/project/Android.mk
,则为Mario
任何人都知道如何通过此错误?