Hi there,
after I've seen the introduction at Devoxx I wanted to migrate a current project from Ant to Gradle.
For the easiest choice I picked the "migrated"-example from the samples and adapted a bit.
This is what it looks like now:
build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.2'
compile fileTree(dir: 'libs', include: '*.jar')
}
}
apply plugin: 'java'
tasks.withType(Compile) {
options.encoding = 'UTF-8'
}
apply plugin: 'android'
android {
target = 'android-16'
defaultConfig {
versionCode = 3
versionName = '1.0.1'
signingStoreLocation = "deployment/debug.keystore"
signingStorePassword = "android"
signingKeyAlias = "androiddebugkey"
signingKeyPassword = "android"
}
sourceSets {
main {
manifest {
srcFile 'AndroidManifest.xml'
}
java {
srcDir 'src'
//exclude 'some/unwanted/package/**'
}
res {
srcDir 'res'
}
assets {
srcDir 'assets'
}
resources {
srcDir 'src'
}
}
test {
java {
srcDir 'tests/src'
}
}
// Could also be done with:
//main.manifest.srcFile 'AndroidManifest.xml'
//main.java.srcDir 'src'
//main.res.srcDir 'res'
//main.assets.srcDir 'assets'
//main.resources.srcDir 'src'
//test.java.srcDir 'tests/src'
}
buildTypes {
debug {
packageNameSuffix = ".debug"
}
staging {
packageNameSuffix = ".staging"
debuggable = true
debugSigned = true
zipAlign = false
}
}
}
My current problem is that I never got it to work properly because I can't find the examples on how to include
a) either the jars in ./libs/ to be used
or
b) the maven dependencies for the libs.
List of used libs:
GoogleAnalytics-1.5.1.jar
android-support-v4.jar
android-support-v7-gridlayout.jar
androlog-1.0.5-sources.jar
androlog-1.0.5.jar
gson-2.2.2-sources.jar
gson-2.2.2.jar
zxing-core-2.0-javadoc.jar
zxing-core-2.0.jar
With the current setup of the file above I get the following error:
Compiling build file './build.gradle' using BuildScriptClasspathScriptTransformer.
FAILURE: Build failed with an exception.
* Where:
Build file './build.gradle' line: 8
* What went wrong:
A problem occurred evaluating root project 'gradletest'.
> No signature of method: org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.compile() is applicable for argument types: (org.gradle.api.internal.file.collections.DefaultConfigurableFileTree) values: [directory 'libs']
Possible solutions: module(java.lang.Object)
I'm just not familiar at all with gradle so I'm pretty much helpless. I'd apriciate if anyone could point me to suggestion on how to get a successful build from where I can explore more options.
Thanks,
Stefan