Here is an example of a Gradle task that creates .jar from classes.jar .
classes.jar file can be found in the /build/intermediates/exploded-aar/ .
Edit: Create a jar file for each Android Librar y project and distribute them separately. Regarding the dependencies required by library projects, add these dependencies to the final project where your library will be used.
For example: you are an Android Library project MyLibProject , which has the following dependencies in build.gradle
dependencies { compile "com.android.support:support-v4:19.+" }
When you create the project, you will get classes.jar for MyLibProject , and those classes.jar will contain only the class from the library project, and not from com.android.support:support-v4:19.+ .
After that, in another project, you add classes.jar as a library dependency in build.gradle , and also define the same dependencies as in MyLibProject .
And if you still need fatJar , see here how to create fatJar using Gradle .
source share