我无法通过 ndk 在 android studio 中编译和 android 应用程序
I cannot compile and android app in android studio by the ndk
我需要编译一个项目,但我需要解决任何错误。我的 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路由是“ndk.dir=/home/javier/Android/Sdk/ndk”
感谢您的帮助
编辑 local.properties 文件,并在 sdk.dir 下添加以下行 -
ndk.dir=/path/to/your/Android/Sdk/ndk/21.3.6528147
然后从 gradle 文件中删除或注释掉 ndkVersion '21.3.6528147'
行。
这应该可以解决问题。
如果您现在收到 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
我需要编译一个项目,但我需要解决任何错误。我的 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路由是“ndk.dir=/home/javier/Android/Sdk/ndk” 感谢您的帮助
编辑 local.properties 文件,并在 sdk.dir 下添加以下行 -
ndk.dir=/path/to/your/Android/Sdk/ndk/21.3.6528147
然后从 gradle 文件中删除或注释掉 ndkVersion '21.3.6528147'
行。
这应该可以解决问题。
如果您现在收到 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