1

I have the following dependencies in my build.gradle:

dependencies {
    compile 'com.google.guava:guava:18.0'
}

It works during compile time and the output jar is generated for my source code (which uses classes like com.google.common.collect.Maps from the guava libraries).

I have a dex task which converts the output jar into a dex file:

task dex(dependsOn: jar, type:Exec) {
    project.dexDir.mkdirs()
    commandLine 'dx', '--dex', '--no-strict', '--output=' + buildDir +'/dex/' + project.name + '.jar', jar.archivePath
}

The problem is that the output jar doesn't have the guava dependencies, so when it's converted to dex, pushed to an android device and run there, I am getting java.lang.ClassNotFoundException: Didn't find class com.google.common.collect.Maps

Is there a way to get the guava dependencies to be included in the output jar for the javaCompile task that generates the output jar from my other source code? Thank you very much in advance!

April C.
  • 21
  • 1

1 Answers1

1

This is usually called a "jar with dependencies" or sometimes, a "fat" jar. This solution is probably what you need:

Community
  • 1
  • 1
Greg Case
  • 3,200
  • 1
  • 19
  • 17