Search code examples
javaandroidgradlejartimber

Building a jar file from a gradle dependency


I need to make dex file from my android project. First, i need to compile my classes to jar. But i need dependencies in jar. otherwise, i'll get about 300 errors because of unknown methods. I need Timber in jar. but i can't find it in the internet. I searched a lot, but no luck. This is the link to the source code in github. https://github.com/JakeWharton/timber
How do i build a jar from this gradle project?


Solution

  • To add gradle library to your project, you need to add implementation "package-group:package-name:package-version" to your build.gradle.

    For Timber, you would do implementation "com.jakewharton.timber:timber:4.7.1".

    If you want to compile your project, with its dependencies into a jar, then you want to look up "fat jars". Gradle Shadowjar is a plugin that does this.