The dependencies element is outside and after the android element. This element declares the dependencies for this module. Dependencies are covered in the following sections.
Note: When you make changes to the build files in your project, Android Studio requires a project sync to import the build configuration changes. Click Sync Now on the yellow notification bar that appears for Android Studio to import the changes.
The app module in this example declares three dependencies:
...
dependencies {
// Module dependency
compile project(":lib")
// Remote binary dependency
compile 'com.android.support:appcompat-v7:19.0.1'
// Local binary dependency
compile fileTree(dir: 'libs', include: ['*.jar'])
}
The app module depends on the lib module, because MainActivity launches LibActivity1 as described in Open an Activity from a Library Module.
compile project(":lib") declares a dependency on the lib module of BuildSystemExample. When you build the app module, the build system assembles and includes the lib module.
The app and lib modules both use the ActionBarActivity class from the Android Support Library, so these modules depend on it.
compile 'com.android.support:appcompat-v7:19.0.1' declares a dependency on version 19.0.1 of the Android Support Library by specifying its Maven coordinates. The Android Support Library is available in the Android Repository package of the Android SDK. If your SDK installation does not have this package, download and install it using the SDK Manager.
Android Studio configures projects to use the Maven Central Repository by default. (This configuration is included in the top-level build file for the project.)
Some modules do not use any binary dependencies from the local file system. If you have modules that require local binary dependencies, copy the JAR files for these dependencies into
compile fileTree(dir: 'libs', include: ['*.jar']) tells the build system that any JAR file inside app/libs is a dependency and should be included in the compilation classpath and in the final package.
For more information about dependencies in Gradle, see Dependency Management Basics in the Gradle User Guide.