【问题标题】:Gradle can't find classpath for android pluginGradle 找不到 android 插件的类路径
【发布时间】:2012-10-18 16:06:27
【问题描述】:

我收到这个错误,说它找不到与 android 插件相关的类路径。使用 gradle 1.2 。

这是错误:

Could not find method classpath() for arguments [org.gradle.api.plugins:gradle-android-plugin:1.2.1]

这是我的build.gradle 文件

//setup external dependency plugins we will use to build a android application
buildscript {
    repositories {
        mavenCentral()
        maven {
            url "https://oss.sonatype.org/content/repositories/snapshots"
        }
    }

    dependencies {
        classpath 'org.gradle.api.plugins:gradle-android-plugin:1.2.1'
    }
}

//apply eclipse plugin
apply plugin: 'eclipse'

//apply android plugin
apply plugin: 'android'

apply plugin: 'maven'

task hello << {
    String value = 'wagwan'
    println 'Hello world!' + value.toUpperCase()
}

谢谢

编辑:我现在收到新错误:

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve group:org.gradle.api.plugins, module:gradle-android-plugin, version:1.2.1.
  Required by:
      :RssUnified:unspecified
   > Could not GET 'http://repo1.maven.org/maven2/org/gradle/api/plugins/gradle-android-plugin/1.2.1/gradle-android-plugin-1.2.1.pom'.
   > Could not GET 'https://oss.sonatype.org/content/repositories/snapshots/org/gradle/api/plugins/gradle-android-plugin/1.2.1/gradle-android-plugin-1.2.1.pom'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

【问题讨论】:

  • 我在您的编辑中没有收到上述错误消息。插件可以成功下载。我用 Gradle 1.2 运行了相同的代码。
  • 我认为我的 cmd 提示符未在工作中使用正确的 Internet 代理。关于如何更改 Windows 7 中用于 cmd.exe 的 Internet 代理的任何想法?
  • 你可以在gradle.propertiesset up a HTTP proxy for Gradle

标签: android gradle


【解决方案1】:

如指南所示,dependencies { classpath ... } 块必须进入 buildscript { ... } 内部。仅针对构建脚本,定义了名为classpath 的配置。

【讨论】:

  • 添加了,似乎找不到必要的 pom 文件。用错误更新我的问题
  • 试试--refresh-dependencies。如果你说哪个版本的 Gradle 等会有所帮助。
  • --refresh-dependencies 仍然失败
  • 好吧,如果您使用代理,则必须让 Gradle 知道。有关详细信息,请参阅Gradle User Guide
猜你喜欢
  • 2013-10-08
  • 1970-01-01
  • 1970-01-01
  • 2021-02-10
  • 1970-01-01
  • 2012-09-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多