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:+"
}
Answer from Timmmm on Stack OverflowAs 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'
}
IllegalAccessErrors: "...FilenameUtils.isSystemWindows()Z from class org.apache.commons.io.FileUtils"
Java.lang.NoClassDefFoundError: org/apache/commons/io/FileUtils
java - Using Apache Commons IO in a Gradle project - Stack Overflow
Writing and using a custom task with third party dependencies - Old Forum Archive - Gradle Forums
Hi,
I'm stuck with this (=Todo app step-by-step with Android Studio) tutorial.
Slide #18 has a note that says to import the Apache Common IO library to use the FileUtils class. I followed the link to download the library. I chose the download link from version 2.4 of the library under the binary section. I unpacked the *.jar files which were included in the zip file into the lib folder of my Android Studio project folder.
The problem is that Android Studio doesn't seem to recognize the library and underlines the FileUtils class and suggests to create a class with that name instead of importing the class from the library.
Do I have to do something additionally?