android - 在Android Studio中添加依赖项时出错

标签 android android-studio android-gradle-plugin build.gradle

当我想将新库添加到 build.gradle 文件时,它会生成错误。 这是我的 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:1.0.0'

        compile 'com.mcxiaoke.volley:library:1.0.+'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

这就是错误

C:\Users\Fakher\Documents\Play_Store_WS\VolleyJson\build.gradle Error:Error:line (10)Gradle DSL method not found: 'compile()' Possible causes:

  • The project 'VolleyJson' may be using a version of Gradle that does not contain the method. Gradle settings
  • The build file may be missing a Gradle plugin. Apply Gradle plugin
  • 最佳答案

    您需要使用模块的build.gradle而不是您的项目。

    关于android - 在Android Studio中添加依赖项时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29778390/

    相关文章:

    android - 在 Android Studio 中使用矢量进行错误渲染

    android - 如何将 Android Studio 指向我的 Java 文件?

    java - 在自定义 java 库模块中编译 android 模块时出现 Gradle 警告 "unspecified depends on libraries but is a jar "

    android - 使用自定义任务构建 android 模块

    java - Android JSONObject - 我如何循环通过一个平面 JSON 对象来获取每个键和值

    java - 从其他 Activity 获取整数变量

    java - WebView编码错误,请指教

    java - 使用自定义 XML 文件的 Android 滑动选项卡

    android - Gradle 构建错误 : Failed to resolve:

    java - 如何在Android Studio中使用javax.xml.transform.stax?