[英]How to set NDK lib path in Gradle?
I'm working on a PDF viewer application using ebookdroid & MuPDF CPP files. 我正在使用ebookdroid和MuPDF CPP文件处理PDF查看器应用程序。 I am having lots of problem with NDK integration in Gradle. 我在Gradle中进行NDK集成时遇到了很多问题。 I've gone through many answers but they have not fixed my problem. 我已经通过了许多答案,但他们没有解决我的问题。
Gradle is giving me the following error message: Gradle给我以下错误消息:
Error:Execution failed for task ':app:compileDebugNdk'.
Error: Your project contains C++ files but it is not using a supported native build system.
Consider using CMake or ndk-build integration with the stable Android Gradle plugin:
https://developer.android.com/studio/projects/add-native-code.html
or use the experimental plugin:
http://tools.android.com/tech-docs/new-build-system/gradle-experimental.
Edit your build.gradle, add defaultConfig.externalNativeBuild.ndkBuild , externalNativeBuild.ndkBuild and sourceSet.main.jni.srcDir options. 编辑build.gradle,添加defaultConfig.externalNativeBuild.ndkBuild , externalNativeBuild.ndkBuild和sourceSet.main.jni.srcDir选项。 See the comments below. 请参阅以下评论。
android {
compileSdkVersion 22
buildToolsVersion "27.0.0"
defaultConfig {
minSdkVersion 18
targetSdkVersion 22
versionCode 1
versionName "1.0"
//add arguments passed to ndkBuild
externalNativeBuild {
ndkBuild {
arguments "NDK_TOOLCHAIN_VERSION=clang", "APP_SHORT_COMMANDS=true", "APP_ALLOW_MISSING_DEPS=true"
arguments "-j" + Runtime.runtime.availableProcessors()
cFlags "-fexceptions"
}
}
ndk {
abiFilters "armeabi-v7a"
}
}
//specify jni source file path
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
jni.srcDir "jni"
}
buildTypes {
debug {
debuggable true
jniDebuggable true
}
}
//specify makefile / CMake file
externalNativeBuild {
ndkBuild {
path 'jni/Android.mk'
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.