【发布时间】:2017-11-17 04:35:48
【问题描述】:
我对 Android 开发并不陌生,但我正在添加原生构建。我想在 Android Studio 中手动设置 .mk 文件位置,但我想不通。我试过这个'
externalNativeBuild {
ndkBuild {
path 'jni/Android.mk'
}
}
但这只是被 gradle build 忽略了。有人能告诉我怎么做吗?以下是我的完整 gradle 文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "my application full name"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
moduleName "nativeegl"
ldLibs "log", "android", "EGL", "GLESv1_CM"
}
}
externalNativeBuild {
ndkBuild {
path 'jni/Android.mk'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
compile files('libs/Vuforia.jar')
}
【问题讨论】:
-
确保将此块作为 android 块的子块。
-
@Alex Cohn,我做到了。但它被原始设置覆盖。我知道有一种方法可以从 Android Studio 手动指向 .mk 文件,我只是不记得如何了。
-
你怎么知道的?您看到了哪些错误消息?
-
Android Studio、android插件、gradle插件哪个版本?您是否尝试删除项目的
.externalNativeBuild目录(如果有)并重新同步? -
@Alex Cohn,我收到错误消息:Gradle project ndkBuild.path is C:\Users\project_path\app\src\main\jni\make_directory\Android.mk 但该文件不存在.我知道是因为我将文件从其原始文件夹中移出以调试其他问题。
标签: android android-ndk java-native-interface android.mk