android - 我无法通过 ndk 在 android studio 中编译和 android 应用程序
问题描述
我需要编译一个项目,但我需要解决任何错误。我的 Android Grandle 插件版本是 3.1.1,Grandle 版本是 4.4
Build file '/home/javier/Descargas/VisitaOficialArriboOfflinev2/VisitaOficialArriboOffline/app/build.gradle' line: 79A problem occurred evaluating project ':app'.> Could not find method ndkversion() forarguments [21.3.6528147] on object of type com.android.build.gradle.AppExtension.
这是我的 build:gardle:app 有错误的行是 ndkversion '21.3.6528147'
//apply plugin: 'com.android.feature' for instant app
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 23
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk{
abiFilters "x86", "armeabi-v7a", "armeabi-v8a", "x86_64"
}
externalNativeBuild {
cmake {
cppFlags ""
}
}
}
buildTypes {
release {
//Remove minifyEnabled true from release if you are getting error while creating final releasing api.
minifyEnabled false
debuggable false
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
//Remove minifyEnabled true from debug if you are getting error while compiling the app. As this time its running debug part.
minifyEnabled false
debuggable true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
cmake {
path file ('CMakeLists.txt')
}
}
// Configure only for each module that uses Java 8
// language features (either in its source code or
// through dependencies).
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
splits {
//....
}
//The line with error
ndkversion '21.3.6528147' }
我的ndk的path route是“ndk.dir=/home/javier/Android/Sdk/ndk” 谢谢大家的帮助
解决方案
编辑 local.properties 文件,并在 sdk.dir 下添加以下行 -
ndk.dir=/path/to/your/Android/Sdk/ndk/21.3.6528147
ndkVersion '21.3.6528147'
然后从 gradle 文件中删除或注释掉该行。
那应该可以解决问题。如果您现在收到CMake was unable to find a build program corresponding to "Ninja"
错误,请卸载 cmake 3.10 并安装 cmake 3.6。
现在一切都应该可以正常工作了,但万一它仍然因为某种原因坚持错误的 cmake,您也可以在 local.properties 文件中添加以下行:
cmake.dir=/path/to/your/Android/sdk/cmake/3.6.4111459
推荐阅读
- gurobi - 如何从 JuMP/Gurobi 获取基本变量列表?
- fortran - fortran中结构相同但子程序不同的两种派生类型
- r - Tidyverse 从字符条件中提取元素
- jquery - 悬停时更改 Shopify 上的 button_label
- javascript - Amazon Quicksight 与 React 本机集成的集成引发未处理的承诺拒绝,[ReferenceError: Can't find variable: HTMLElement]
- docker - Prometheus Operator 更改 scrape_interval
- python - 如何在所有 AWS 区域自动执行 EBS 加密?
- excel - 将 VBA 代码更改为按 B 列排序,而不是现在正在执行的操作
- python - 对于有间隙的网格数据,是否有替代 np.reshape 的方法?
- javascript - 仅使用 javascript 清除表单下拉列表