Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AAR in Eclipse ANT project

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?

like image 975
czajna666 Avatar asked May 21 '14 08:05

czajna666


People also ask

How add AAR to project?

Add your AAR or JAR as a dependencyNavigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Jar Dependency in the dropdown. In the Add Jar/Aar Dependency dialog, first enter the path to your . aar or .

What is AAR file in Java?

An AAR file contains a software library used for developing Android apps. It is structurally similar to an . APK file (Android Package), but it allows a developer to store a reusable component that can be used across multiple different apps.


2 Answers

This solution was helpful for me

EDIT: A .aar file is simply a zip file with the following contents:

  1. AndroidManifest.xml (Required file)
  2. classes.jar (required file)
  3. Res / (compulsory folder)
  4. R.txt (Required file)
  5. Assets / (Optional folder)
  6. libs/*.jar (folder option)
  7. jni//*.so (optional folder)
  8. proguard.txt (optional file)
  9. lint.jar (optional file)

You see, within the .aar file you have everything you need to operate the library in eclipse.

to create library:

  1. CREATE a new project (hereafter library project ) to your workspace. Do not forget to mark it as a library.
  2. Leave empty src folder library project .
  3. .aar Decompresses the file. You can rename it to .zip and unzip or use any tools.
  4. Copy the file classes.jar into the libs file folder library project .
  5. Res folder replaces the library project with .aar res file folder.
  6. 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.

  1. In the project you want to use the library (henceforth, project goal ) added as the dependency library project .
  2. 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 .
  3. If there is, copy the entire contents of the folder assets .aar file in the assets folder target project .
  4. If there is, copy the entire contents of the file .aar libs folder in folder libs target project .

  5. Make a Clean the workspace and recompiled.

http://www.iphonedroid.com/blog/utilizar-ficheros-aar-en-eclipse/#.Vh3krye1Gko

like image 65
Ahmed Mostafa Avatar answered Oct 21 '22 22:10

Ahmed Mostafa


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:

https://stackoverflow.com/a/21417599/1836870

like image 30
PedroCactus Avatar answered Oct 21 '22 22:10

PedroCactus