如何添加依赖项

下面的示例描述了如何在 app / module 的 build.gradle 文件中声明三种不同类型的直接依赖项:

   android {...}
    ...
    dependencies {
        // The 'compile' configuration tells Gradle to add the dependency to the
        // compilation classpath and include it in the final package.
    
        // Dependency on the "mylibrary" module from this project
        compile project(":mylibrary")
    
        // Remote binary dependency
        compile 'com.android.support:appcompat-v7:24.1.0'
    
        // Local binary dependency
        compile fileTree(dir: 'libs', include: ['*.jar'])
    }