您应该使用实验性插件进行NDK目的:
所以你的build.gradle(主项目)将如下所示:
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle-experimental:0.4.0' } } allprojects { repositories { jcenter() } }
和build.gradle(app)看起来像:
apply plugin: 'com.android.model.application' model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.2" defaultConfig.with { applicationId = "com.sample.codecator" minSdkVersion.apiLevel = 19 targetSdkVersion.apiLevel = 19 } } }
如果您使用的是任何库模块,那么build.gradle
它将如下所示:
apply plugin: 'com.android.model.library' model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.2" defaultConfig.with { minSdkVersion.apiLevel = 19 targetSdkVersion.apiLevel = 19 } } }
您应该将以下内容排除在外android{...}
:
android.buildTypes android.sources android.productFlavors
喜欢:
model { android { compileSdkVersion = 23 buildToolsVersion = "23.0.2" defaultConfig.with { minSdkVersion.apiLevel = 19 targetSdkVersion.apiLevel = 19 } android.buildTypes { release { minifyEnabled = false proguardFiles.add(file("proguard-rules.pro")) } } android.productFlavors { // } android.sources { // } }
不要忘记ndk.dir=ndk_path
在您的local.properties
文件中设置.
UPDATE
更新android.buildTypes
所有文件中的代码,如下所示:
android.buildTypes { release { minifyEnabled = false proguardFiles.add(file("proguard-rules.pro")) } }