is there any way to use .aar library (with resources) in eclipse ant project? I know that there is no simply way to use .aar format like in gradle, but maybe there is some workaround to unzip it and import it manually?
4 Answers
This solution was helpful for me
EDIT: A .aar file is simply a zip file with the following contents:
- AndroidManifest.xml (Required file)
- classes.jar (required file)
- Res / (compulsory folder)
- R.txt (Required file)
- Assets / (Optional folder)
- libs/*.jar (folder option)
- jni//*.so (optional folder)
- proguard.txt (optional file)
- lint.jar (optional file)
You see, within the .aar file you have everything you need to operate the library in eclipse.
to create library:
- CREATE a new project (hereafter library project ) to your workspace. Do not forget to mark it as a library.
- Leave empty src folder library project .
- .aar Decompresses the file. You can rename it to .zip and unzip or use any tools.
- Copy the file classes.jar into the libs file folder library project .
- Res folder replaces the library project with .aar res file folder.
- You've created the project that contains almost everything you need.
Now let's see how to configure your project to reference the library project.
- In the project you want to use the library (henceforth, project goal ) added as the dependency library project .
- Open AndroidManifest.xml .aar within the file and make sure to copy everything it takes (permits, activities, services, receivers ...) in the file AndroidManifest.xml project objective .
- If there is, copy the entire contents of the folder assets .aar file in the assets folder target project .
If there is, copy the entire contents of the file .aar libs folder in folder libs target project .
Make a Clean the workspace and recompiled.
http://www.iphonedroid.com/blog/utilizar-ficheros-aar-en-eclipse/#.Vh3krye1Gko

- 918
- 1
- 12
- 20
-
1While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Onik Oct 14 '15 at 08:59
-
@Onik Thank you, I will – Ahmed Mostafa Oct 14 '15 at 19:47
-
1Why I get -1 for the answer ?! – Ahmed Mostafa Oct 14 '15 at 23:39
-
1This answer certainly deserves a +1. – neevek Dec 09 '16 at 14:54
-
I did not create, new library project. I just extract .aar file, copy the library from libs folder to libs folder to the project where i want to use and add to Build path, also copy manifest content, and res folder. Now i'm able to reference/use lib. – No Name Apr 30 '17 at 01:53
Indeed, aar files are just archive files. So you can unzip it and find jar files along with ressources files. The question have already been partially answered here:
https://stackoverflow.com/a/21485222/1836870
If you want to get the ressources inside your jar, you could try repackage like it's suggested in this answer:

- 1
- 1

- 525
- 4
- 10
-
2
-
@ShajeelAfzal , this is a simple zip archive. just change an extention. https://support.apple.com/kb/ph19072?locale=en_US – Vyacheslav Nov 14 '16 at 12:48
The brunt of the work can be done by a wonderful script called deaar. The gist explains things, but basically you run:
ruby deaar.rb [path/to/aar] [output_directory]
It outputs an almost ready to use library. Next, you need to run:
cd [output_directory]
android update lib-project -p . -t android-xx
Replace xx with the Android version you're targeting. Now put that directory where your build.xml and project.properties are. Finally, add a line like this to your project.properties:
android.library.reference.1=./output_directory
Replace the directory name with the one you created. You can use ".2" and so on for additional libraries. And that's it!

- 340
- 1
- 7
-
1This made it possible for me to build a Google VR application within an Android ant project! Just a note that should be clear, there is one step that must be done to correctly integrate the library and it's that a given aar won't have any project.propertiesyou must be sure to have one and set android.library=true (in other case you'll get an UNEXPECTED TOP-LEVEL EXCEPTION with classes.jar when building the project - thanks to http://stackoverflow.com/a/19332059/939781 ) – DNax Nov 09 '16 at 18:26
-
The `android update lib-project` line given above will create the project.properties for you. – goobliata Dec 04 '16 at 04:57
Twitter Fabric(Crashlytics) has a kits-libs plugin for dependencies management http://docs.fabric.io/android/fabric/eclipse.html.
And there's another gradle plugin project https://github.com/ksoichiro/gradle-eclipse-aar-plugin.

- 180
- 1
- 7
-
1Sadly Fabric pulled out... *With Google dropping support for Eclipse, after much thought, we’ve decided to discontinue support for Eclipse. We recommend switching to Android Studio.* – Hunter-Orionnoir Apr 13 '17 at 19:14