如何在 Android Studio 1.3 中配置 NDK 项目
我一直在尝试按照 this 为 NDk 配置 Android Studio文章和这篇文章.以下是我的gradle-wrapper.properties的内容
I have been trying to configure Android Studio for NDk by following this article and this article. The following are the contents of my gradle-wrapper.properties
#Sat Aug 08 09:36:53 IST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.5-all.zip
以下是build.gradle(project)的内容
Following is the contents of build.gradle(project)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle-experimental:0.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
最后是 build.gradle(module)
and finally the build.gradle(module)
apply plugin: 'com.android.model.application'
model {
android {
compileSdkVersion = 22
buildToolsVersion = "23.0.0 rc3"
defaultConfig.with {
applicationId = "com.opaxlabs.nativetest"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 22
versionCode = 1
versionName = "1.0"
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
}
}
}
android.ndk{
moduleName = "native"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
}
当我尝试同步 gradle 文件时,出现以下错误:
when I try to sync gradle files I get the following error:
Error:No such property: android for class: com.android.build.gradle.managed.AndroidConfig
local.properties 中定义了以下路径
the following paths are defined in local.properties
ndk.dir=/opt/adt-bundle-linux-x86_64-20140702/sdk/ndk-bundle
sdk.dir=/opt/adt-bundle-linux-x86_64-20140702/sdk
所以看起来我错过了一些东西,只是我找不到它.任何帮助将不胜感激.
so it looks like I have missed something only I can't locate it. Any help will be greatly appreciated.
在你的 build.gradle(module) 中,android.buildTypes 块需要在 android 之外> 阻止.所以它应该是这样的:
In your build.gradle(module), the android.buildTypes block needs to outside of the android block. So it should look like this:
model {
android {
compileSdkVersion = 22
buildToolsVersion = "23.0.0 rc3"
defaultConfig.with {
applicationId = "com.opaxlabs.nativetest"
minSdkVersion.apiLevel = 15
targetSdkVersion.apiLevel = 22
versionCode = 1
versionName = "1.0"
}
}
android.buildTypes {
release {
minifyEnabled = false
proguardFiles += file('proguard-rules.pro')
}
}
android.ndk{
moduleName = "native"
}
}