【问题标题】:Android Studio first project errorAndroid Studio 第一个项目报错
【发布时间】:2014-08-07 07:50:28
【问题描述】:

我已经在 OS X (10.9.3) 上成功安装了 Android Studio (0.6.1)。我无法获得我的第一个 Hello World!项目...请帮我解决这个问题

这是我得到的错误:

Error:(19, 0) 构建脚本错误,发现不支持的 Gradle DSL 方法: 'android()'!

可能的原因可能是:
- 您正在使用该方法不存在的 Gradle 版本(修复 Gradle 设置) - 你没有应用提供方法的 Gradle 插件(应用 Gradle 插件) - 或者构建脚本中有错误(转到源)

更新:(代码、错误消息)

脚本:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {}
}

apply plugin: 'android'

repositories {
    mavenCentral()
}

android {
    compileSdkVersion 19
    buildToolsVersion '19.1'
    defaultConfig {}
    productFlavors {
    }
}

dependencies {
}

错误信息:

错误:(8, 0) 未找到 ID 为“android”的插件。

【问题讨论】:

  • 编写你的 build.gradle 文件。
  • @EugenMartynov 它仍然无法正常工作......
  • 我应该重新安装吗?
  • 与 build.gradle 共享。 Android Studio 没问题

标签: android android-studio


【解决方案1】:

修改为下一个:

buildscript {
  repositories {
    mavenCentral()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:0.11.+'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
  } 
}

apply plugin: 'android' 

repositories {
  mavenCentral()
} 

android {
  compileSdkVersion 19
  buildToolsVersion '19.1.0'
  defaultConfig {}
  productFlavors {
  } 
}

dependencies { }

【讨论】:

  • 复制粘贴整个代码行不行(替换原来的)
  • 当然,这实际上是您的代码稍作修改
  • 现在我得到这个错误:Error:(11, 0) Plugin with id 'android' not found.this post 没有解决问题..
  • 你的gradle版本是什么gradle -v
  • 我不确定 gradle 版本是什么......如果我在终端中输入它,我会得到:bash: gradle: command not found
猜你喜欢
  • 2014-09-19
  • 2017-09-24
  • 1970-01-01
  • 2013-06-24
  • 2013-07-04
  • 1970-01-01
  • 2021-08-05
  • 1970-01-01
  • 2018-09-25
相关资源
最近更新 更多