Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to create a jar file from android studio

I have a fairly latest version of android studio, I have created a module under a project which is basically supposed to be a library, when I build it, it creates an ".aar" file , what I want is .jar file as this library is supposed to be used with eclipse as well.

The library contains activity as well, is there any way by which I can create a .jar file which I can use on Eclipse as well Android Studio ?

I have already created this module and tried building , as a result it generated .aar file and not a .jar file.

like image 796
vishal dharankar Avatar asked Jun 11 '15 13:06

vishal dharankar


2 Answers

I found a way to achieve this, plain simple, using Gradle 2.2.1:

task jar(type: Jar, dependsOn: 'assembleRelease') {
    from fileTree(dir: 'build/intermediates/classes/release')
}

Place this in your library module. It will compile it as release and produce a JAR file in: build/libs.

bash gradlew jar or use your IDE to target that jar Gradle task.

like image 126
shkschneider Avatar answered Oct 22 '22 06:10

shkschneider


aar is not related to AS or eclipse but is an AndroidARchive for Android applications like JavaARchives are for java applications. Because Android is java based, jars can be used. But to take android specialities into account, like resource bundles, an aar is the right thing to use.

like image 39
sschrass Avatar answered Oct 22 '22 05:10

sschrass