如何与Android摇篮插件0.7配置NDK [英] How to configure NDK with Android Gradle plugin 0.7
问题描述
新的Android插件的gradle(0.7)似乎包括对NDK新的支持,但在文档中很少有不提它(我发现的唯一引用是一个名为test <一个href=\"https://android.googlesource.com/platform/tools/build/+/2e1f7810edd76d92cee8d3e06bc4dec0c288adea/tests/ndkSanAngeles/build.gradle\"><$c$c>ndkSanAngeles$c$c>).
The new Android gradle plugin (0.7) seems to include new support for the NDK, but in the documentation there is little to no mention of it (the only reference I found is a test called ndkSanAngeles
).
看起来gradle这个正在寻找NDK,我已经包含在我的道路。然而,建立项目失败
It looks like gradle is looking for the NDK, which I have included in my PATH. However, building the project fails with
- 出了什么问题:
执行失败的任务:OGLTests:compileDefaultFlavorDebugNdk。
NDK未配置
我如何配置NDK的gradle中?
How can I configure the NDK in gradle?
我目前的build.gradle看起来是这样的:
My current build.gradle looks like this:
task nativeLibsToJar(type: Zip, description: 'create a jar with native libs') {
destinationDir file("$buildDir/native-libs")
baseName 'native-libs'
extension 'jar'
from fileTree(dir: 'src/main/libs', include: '**/*.so')
from fileTree(dir: 'src/main/libs', include: '**/gdb*')
into 'lib/'
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn nativeLibsToJar
}
dependencies {
compile fileTree(dir: "$buildDir/native-libs", include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion '19.0.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "0.1"
}
buildTypes {
release {
runProguard false
}
debug {
// jniDebugBuild true
runProguard false
debuggable true
}
}
productFlavors {
defaultFlavor {
proguardFile 'proguard-rules.txt'
}
}
}
感谢。
推荐答案
找到了答案。包括 ndk.dir =路径/要/ NDK
在 local.properties
文件并获得成功。
Found the answer. Including ndk.dir=path/to/ndk
in the local.properties
file did the trick.
更新:
在Android工作室的最新版本,你可以在项目结构> SDK位置直接设定值。
Update: On the latest versions of Android Studio, you can set the value directly in the Project Structure > SDK location.
这篇关于如何与Android摇篮插件0.7配置NDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!