Search code examples
javajaraar

How to convert AAR to JAR


Situation:

I intend to use a Java library and I only have an AAR file from a Maven repository but I need the JAR file.

Background story:

I tried to compile a library, but its Gradle structure was unstable. So I asked for a compiled jar file, and its developer handed me an aar file from some Maven repository (the developer couldn't compile his own project). The Gradle configuration was a mess, it depended on multiple libraries and Gradle has thrown some exceptions.

I tried to use it in my IDEA IDE, but it couldn't see it. A library project should be able to be compiled into a jar file, right?

Question:

What should I do to convert that AAR file to a JAR file?


Solution

  • The AAR file consists of a JAR file and some resource files (it is basically a standard zip file with a custom file extension). Here are the steps to convert:

    1. Extract the AAR file using standard zip extract (rename it to *.zip to make it easier)
    2. Find the classes.jar file in the extracted files
    3. Rename it as you like and use that jar file in your project