I have successfully imported ActionBarSherlock to my project, and need to import another two libraries: Sliding Layer and Crouton. I know that similar questions have already appeared here before, but I've tried almost everything, each time breaking something in the project in a way that I had to start over.
My project tree looks like:
MyProject/
+ app/
+ libraries/
+ actionbarsherlock/
+ crouton/
+ slidinglayer/
I imported those two libraries as modules (File->Import Module)
My setting.gradle file looks like it should:
include ":libraries:actionbarsherlock", ':Krypto', ':libraries:crouton', ':libraries:slidinglayer'
actionbarsherlock gradle:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile files('libs/android-support-v4.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
app gradle:
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
dependencies {
compile project(":libraries:actionbarsherlock")
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
slidinglayer gradle:
apply plugin: 'android-library'
dependencies {
compile "com.android.support:support-v4:18.0.0"
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 4
targetSdkVersion 18
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
res.srcDirs = ['res']
}
}
}
In crouton folder there is no gradle.build file. How it should look like? Theres only java files (no resources).
How to set up correctly dependencies in crouton and slidinglayer libraries?
build.gradle for crouton
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android-library'
dependencies {
compile 'com.android.support:support-v4:18.0.0'
}
android {
compileSdkVersion 18
buildToolsVersion "18.0.1"
defaultConfig {
minSdkVersion 9
targetSdkVersion 17
}
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
}
}
}
and in your app build.gradle, change
dependencies {
compile project(":libraries:actionbarsherlock")
}
to
dependencies {
compile project(":libraries:actionbarsherlock")
compile project(":libraries:crouton")
compile project(":libraries:slidinglayer")
}
and import again in Android Studio
I don't know how to solve your problem, but when I faced problem of third party library use in Gradle build, I solved by following way.
Following is my structure of project.
GsonDemoProject
GsonDemo
build
libs
android-support-v4.jar
gson.jar
src
main
build.gradle
build.gradle
settings.gradle
I edited my build.gradle
file which resides in src
directory.
dependencies {
compile files('libs/android-support-v4.jar','libs/gson.jar')
}
I put reference of 3rd party library in dependencies
tag like above. In my project libs
is directory where libraries are put.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With