Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create an Android Jar library for distribution

Tags:

java

android

jar

I know of Android Library projects, which allow you to create a shared-source project that can be pulled into Android Applications as needed. However, that requires that source be available.

I'm looking for a way to build and distribute a closed-source library that can be used in other Android projects like a traditional JAR. This will require usage of the Android compiler, so it's not a vanilla-Java JAR file. FWIW, I do not need to embed resources/layouts in the JAR.

I've seen http://andparcel.com/ but it feels like a workaround, and I would rather use something 'officially supported' by Google. Also, I need to make sure that the JAR I build is compatible with old/new version of the Android SDK (i.e. I need a way to set the target platform version, etc).

Do the latest Android toolsets allow for the creation/consumption of JAR binaries? Can you point to some documentation on how I can do it?

like image 202
psychotik Avatar asked Feb 16 '11 08:02

psychotik


People also ask

What is the difference between AAR and jar?

The main difference is aar is splitted inside android to jar. If your app will be used only in user app only in android studio then aar is preferred. If you are planning for app to communicate with c/c++ compiled lib.so file jar is preferred.

What is AAR Android?

The . aar bundle is the binary distribution of an Android Library Project. An AAR is similar to a JAR file, but it can contain resources as well as compiled byte-code. A AAR file can be included in the build process of an Android application similar to a JAR file.


1 Answers

If you create a Android Library project without having any resources, the ADT (first noticed in r16) will create a .jar with the same name as the project in the 'bin' folder.

like image 109
Freddroid Avatar answered Oct 17 '22 21:10

Freddroid