我已经获得了一个帮助的项目,但是我无法完成它的工作,而那些给我的人就像我一样难住。我们正在使用Android Studio 2.1.2为Google Glass制作Android软件。此外,我们一直在设置SDK等。Google Glass,Gradle没有找到DSL方法:'android()'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
android {
compileSdkVersion 'Google Inc.:Glass Development Kit Preview:19'
buildToolsVersion '23.0.1'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
}
这是主要的build.gradle文件。然后,在应用程序文件夹中,如果这很重要,则该文件在于。也build.gradle。
apply plugin: 'com.android.application'
repositories {
jcenter()
}
android {
compileSdkVersion 'Google Inc.:Glass Development Kit Preview:19'
buildToolsVersion '23.0.1'
final def config = defaultConfig {
unimportant stuff
}
config
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
buildTypes {
release {
things
}
}
dexOptions {
hopefully unimportant
}
productFlavors {
}
}
dependencies {
a considerable amount
}
现在,我得到了问题“Gradle DSL method not found:android()”。这里有更多的问题需要询问。所以,根据那些回答的建议,我试图从顶层gradle中删除android和依赖项。我结束了以下错误。 “无法设置SDK。模块”应用程序“:platform'Google Inc.:Glass Development Kit Preview:19'not found。”这尽管一切都成立了。
现在请注意,代码看起来很明显起作用,就像我为代码从那里获得代码一样。我的一些事情是非常错误的。我在问互联网的好人,你知道什么可能是错的吗?
它使声明“Gradle DSL method not found:'hasPlugin()'。” – PlatinumSkink
更改为'plugins.hasPlugin(...)' –
嗯。完成后,我现在得到“Error:Module'app':平台'Google Inc.:Glass Development Kit Preview:19'找不到。”,这听起来像是一个单独的问题。但是,这是android事物编译SDK的一部分。这也是我从根项目中删除android和依赖关系时遇到的问题。 ...天哪,这是有问题的。我认为这意味着它没有通过hasPlugin if语句。我如何解决这个问题?包括“apply plugin:'com.android.application'”在我以前尝试过时不起作用。 – PlatinumSkink