2012-10-29 49 views
5

tôi nhận được lỗi này nói rằng nó không thể tìm thấy classpath liên quan đến một plugin android. sử dụng gradle 1.2.Gradle không thể tìm thấy classpath cho android plugin

đây là lỗi:

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

đây là tập tin build.gradle tôi

//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() 
} 

Cảm ơn

chỉnh sửa: Lỗi mới tôi nhận được bây giờ:

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. 
+0

Tôi không nhận được thông báo lỗi được đề cập ở trên trong bản chỉnh sửa của bạn. Plugin có thể được tải xuống thành công. Tôi chạy cùng một mã với Gradle 1.2. –

+0

Tôi nghĩ rằng dấu nhắc cmd của tôi không sử dụng đúng proxy internet tại nơi làm việc. bất kỳ ý tưởng về cách tôi có thể thay đổi proxy internet được sử dụng cho cmd.exe trong windows 7? – jonney

+0

Bạn có thể [thiết lập proxy HTTP cho Gradle] (http://www.gradle.org/docs/current/userguide/build_environment.html) trong 'gradle.properties'. –

Trả lời

17

Như đã trình bày trong guid e, khối dependencies { classpath ... } phải đi vào bên trong buildscript { ... }. Chỉ dành cho kịch bản lệnh xây dựng, cấu hình có tên là classpath được xác định.

+0

Thêm vào đó và có vẻ như nó không thể tìm thấy các tập tin pom cần thiết. đang cập nhật câu hỏi của tôi với lỗi – jonney

+0

Hãy thử '--refresh-dependencies'. Nó sẽ giúp đỡ nếu bạn nói phiên bản Gradle, vv .. –

+0

gradle 1.2 i am using – jonney

Các vấn đề liên quan