我想使用Gson和Retrofit与API进行交互。根据该文档,我加论文线到我的项目的build.gradle:未找到gradle dsl方法'compile()'错误:(10,0)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral() //this line
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
compile 'com.google.code.gson:gson:2.7' //this line
compile 'com.squareup.retrofit:retrofit:1.9.0' //this line
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral() //and this line
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
但我有这些错误:
Error:(10, 0) Gradle DSL method not found: 'compile()' Possible causes:
The project 'TempoEDF' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0). Upgrade plugin to version 2.3.3 and sync project The project 'TempoEDF' may be using a version of Gradle that does not contain the method. Open Gradle wrapper file The build file may be missing a Gradle plugin. Apply Gradle plugin
所以我用的摇篮插件像我的IDE希望:
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
apply plugin: 'gradle'
compile 'com.google.code.gson:gson:2.7'
compile 'com.squareup.retrofit:retrofit:1.9.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
但我有此错误:
Error:(10, 0) Plugin with id 'gradle' not found. Open File
我做错了什么?
将这些行添加到应用程序级gradle文件 – Onkar