gpt4 book ai didi

Android Studio 中的 Android NDK 构建过程

转载 作者:行者123 更新时间:2023-11-29 17:39:16 27 4
gpt4 key购买 nike

我正在尝试获取 antidote 的示例应用程序正在运行(source code)。

我对如何在 Android Studio 中运行我的应用感到困惑。我将 C 源文件放在 /jni 文件夹中,安装 Cygwin 并运行命令 ../android/android-ndk-r10d/ndk-build NDK_PROJECT_PATH=app/src/main/ 来自 /myworkspace/myApp 文件夹。

我似乎没有收到任何错误,并且已经创建了一个 /libs 文件夹,其中包含一个库,如下图所示。

Tree of files

但是,当点击绿色运行按钮时,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

关于Android Studio 中的 Android NDK 构建过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29332004/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com