Android Android Studio 中的 NDK 构建过程
Android NDK-build process in Android Studio
我正在尝试获取 antidote running (source code) 的示例应用程序。
我对如何在 Android Studio 中 运行 我的应用感到困惑。我将 C 源文件放在 /jni
文件夹中,安装了 Cygwin 和 运行 来自 /myworkspace/myApp
文件夹中的命令 ../android/android-ndk-r10d/ndk-build NDK_PROJECT_PATH=app/src/main/
。
我似乎没有收到任何错误,并且已经创建了一个 /libs
文件夹,其中包含一个库,如下图所示。
但是,当单击绿色 运行 按钮时,Android Studio 仍然在 :app:compileDebugNdk
中给出错误。代码既然编译好了,ndk还需要运行吗?我该如何关闭它?我还需要以某种方式安装 ndk-build 制作的库吗?
这是我的 build.gradle
项目:
sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
这是模块的 build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.signove.health.service"
minSdkVersion 15
targetSdkVersion 21
}
sourceSets.main{
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
您要禁用来自 sourceSets.main{ jni.srcDirs = [ ] } 的自动 ndk-build 调用,然后您可能需要 Gradle 插件调用它添加 ndkBuild 任务.
检查这个答案:execution failed for task ':app:compileDebugNdk' failed to run this command ndk-build.cmd
我正在尝试获取 antidote running (source code) 的示例应用程序。
我对如何在 Android Studio 中 运行 我的应用感到困惑。我将 C 源文件放在 /jni
文件夹中,安装了 Cygwin 和 运行 来自 /myworkspace/myApp
文件夹中的命令 ../android/android-ndk-r10d/ndk-build NDK_PROJECT_PATH=app/src/main/
。
我似乎没有收到任何错误,并且已经创建了一个 /libs
文件夹,其中包含一个库,如下图所示。
但是,当单击绿色 运行 按钮时,Android Studio 仍然在 :app:compileDebugNdk
中给出错误。代码既然编译好了,ndk还需要运行吗?我该如何关闭它?我还需要以某种方式安装 ndk-build 制作的库吗?
这是我的 build.gradle
项目:
sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
这是模块的 build.gradle
:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.signove.health.service"
minSdkVersion 15
targetSdkVersion 21
}
sourceSets.main{
jni.srcDirs = []
jniLibs.srcDir 'src/main/libs'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
您要禁用来自 sourceSets.main{ jni.srcDirs = [ ] } 的自动 ndk-build 调用,然后您可能需要 Gradle 插件调用它添加 ndkBuild 任务.
检查这个答案:execution failed for task ':app:compileDebugNdk' failed to run this command ndk-build.cmd