Add commons-io dependency to gradle project in Android Studio
As of now (May 2014) if you use the default generated project it is actually amazingly simple (though difficult to find instructions!
Open the second level build.gradle, and add the following line to the dependencies {
:
compile "commons-io:commons-io:+"
That will get the latest version of commons-io
. My complete file looks like this:
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 18
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile "commons-io:commons-io:+"
}
you need to declare a repository where you want to resolve the commons-io library from (e.g. MavenCentral):
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories{
mavenCentral()
}
dependencies {
compile files('libs/android-support-v4.jar')
compile group: 'commons-io', name: 'commons-io', version: '2.0.1'
}