Tutorial by Examples

The example below describes how to declare three different types of direct dependencies in the app/ module's build.gradle file: android {...} ... dependencies { // The 'compile' configuration tells Gradle to add the dependency to the // compilation classpath and inclu...
To download dependencies, declare the repository so Gradle can find them. To do this, add a repositories { ... } to the app/ module's build.gradle in the top-level file. repositories { // Gradle's Java plugin allows the addition of these two repositories via method calls: jcenter() mavenCe...
In a multi-project gradle build, you can have a dependency with another module in your build. Example: dependencies { // Dependency on the "mylibrary" module from this project compile project(":mylibrary") } The compile project(':mylibrary') line decla...
You can have a dependency with a single jar or multiple jar files. With a single jar file you can add: dependencies { compile files('libs/local_dependency.jar') } It's possible to add a directory of jars to compile. dependencies { compile fileTree(dir: 'libs', include: ['*.jar']...
You can add remote dependencies in Gradle usign this structure: compile 'group:name:version' or this alternative syntax: compile group: 'xxx', name: 'xxxxx', version: 'xxxx' For example: compile 'com.android.support:appcompat-v7:24.1.0' The compile 'com.android.support:appcompat-v7:24.1....
Dependencies can be added for specific configuration like test/androidTest androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.1' testCompile 'junit:junit:3.8.1' Alternatively create your own configuration configurations { myconfig } And then download dependency fo...
Dependencies can be added for specific product flavors in a similar fashion as build configurations. android { ... productFlavors { flavor1 { //... } flavor2 { //... } } } dependencies { flavor1Compile 'com.and...
Dependencies can be added for specific Build types: android { ... buildTypes { release { //... } debug { //.... } } } dependencies { debugCompile 'com.android.support:appcompat-v7:24.1.1' releaseCompile ...

Page 1 of 1