【发布时间】:2016-09-20 20:55:36
【问题描述】:
我正在使用 android studio 2.1.3 来自Create Hello-JNI with Android Studio
编译时输出如下。
错误:(3, 0) Gradle DSL 方法未找到:'android()' 可能的原因:
项目“FirstDemo”可能正在使用不包含该方法的 Android Gradle 插件版本(例如,在 1.1.0 中添加了“testCompile”)。 修复插件版本并同步项目 项目“FirstDemo”可能正在使用不包含该方法的 Gradle 版本。 打开 Gradle 包装文件 构建文件可能缺少 Gradle 插件。 应用 Gradle 插件
build.gradle(模块):
apply plugin: 'com.android.model.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.sprinkle.firstdemo"
minSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
buil.gradle(顶部)
// 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.7.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
//task clean(type: Delete) {
// delete rootProject.buildDir
//}
【问题讨论】:
-
android {} 应该包含在模型 {} 中。它在教程中。
-
嗨,我试过了,我得到了错误 org.gradle.api.internal.ExtensibleDynamicObject
-
所以试图删除模型
-
你试过不使用实验性 gradle 插件吗?我认为当前版本的标准插件支持原生代码。
-
哦...原因是 android 2.1.3 和教程给出的版本。谢谢,我会尝试不使用实验性 gradle 插件。