Dependencies, Android Libraries and Multi-project setup
Dependency Local & Remote1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| repositories { mavenCentral() }
dependencies { compile files('libs/foo.jar')
compile 'com.google.guava:guava:11.0.2' }
android { ... }
|
Complile
- compile: main application
- testCompile: test application
- debugCompile: debug Build Type
- releaseCompile: release Build Type.
- <buildtype>Compile: (Ex: alphaCompile, betaCompile)
Multi project setup
MyProject/
├── settings.gradle
├── build.gradle
├── app/
│ └── build.gradle
└── libraries/
├── lib1/
│ └── build.gradle
└── lib2/
└── build.gradle
setting.gradle1 2 3 4
|
include ':app', ':libraries:lib1', ':libraries:lib2'
|
app/build.gradle1 2 3 4 5 6
| dependencies { compile project(':libraries:lib1') compile project(':libraries:lib2') }
|
If you want to share code that accesses Android APIs or uses Android-style resources
these libraries cannot be regular Java project, they have to be Android Library Projects.
lib2/build.gradle1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| buildscript { repositories { mavenCentral() }
dependencies { classpath 'com.android.tools.build:gradle:0.5.6' } }
apply plugin: 'android-library'
android { compileSdkVersion 15 }
|
…