我是Android Studio和Android开发人员以及开发我的第一个应用程序的新手。在Gradle Android Studio中找不到方法compile()
我想用CarView
和RecyclerView
来显示数据。据上很多教程,我需要添加以下的依赖
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
这是我build.gradle
怎么
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
dependencies {
compile 'com.android.support:cardview-v7:21.0.+'
compile 'com.android.support:recyclerview-v7:21.0.+'
}
但在同步gradle这个,它提供了错误的
Error:Could not find method compile() for arguments [com.android.support:cardview-v7:21.0.+] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK Manager.
我尝试了谷歌搜索的许多解决方案,但找不到任何工作。