How to convert AAR to JAR
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:
- Extract the AAR file using standard zip extract (rename it to *.zip to make it easier)
- Find the classes.jar file in the extracted files
- Rename it as you like and use that jar file in your project
How to convert an .aar file into a .jar
I need to convert an .aar file into a .jar
By definition, an AAR is not a JAR and cannot necessarily be "converted" into a JAR.
Frequently, if the artifact is distributed as an AAR, instead of a JAR, that is because there is more than just Java code that is part of the artifact.
I mean, at the Android SDK, the extras/android/m2repository/com/android/support/support-v4 libraries only have classes until 24.1 version
Correct. Since then, support-v4
has merely been a container for transitive dependencies. You will see a list of them in the POM file adjacent to the artifact.
For example, the 25.3.1
POM file shows all of the artifacts that will be pulled in when you use support-v4
in an AAR-artifact-aware IDE (Android Studio, IntelliJ IDEA, etc.):
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.android.support</groupId>
<artifactId>support-v4</artifactId>
<version>25.3.1</version>
<packaging>aar</packaging>
<dependencies>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-compat</artifactId>
<version>25.3.1</version>
<type>aar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-media-compat</artifactId>
<version>25.3.1</version>
<type>aar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-core-utils</artifactId>
<version>25.3.1</version>
<type>aar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-core-ui</artifactId>
<version>25.3.1</version>
<type>aar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.android.support</groupId>
<artifactId>support-fragment</artifactId>
<version>25.3.1</version>
<type>aar</type>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
As you can see from the <type>
elements, most of those transitive dependencies themselves are AARs.
Sometimes, the AAR does not contain much other than a JAR.
For example, the 25.3.1
edition of support-core-utils
— one of the AARs that support-v4
pulls in — has nothing of importance other than its classes.jar
that I can see.
However, other AARs have things beyond the JAR. For example, support-compat
and support-media-compat
have AIDL files. Other AARs — such as appcompat-v7
— have resources or assets. If you try just using the JAR out of the AAR, and you try using a class that expects those resources or AIDL files or whatever to exist, your app will crash.
You can attempt to convert an AAR into an old-style Eclipse library project. As the saying goes, your mileage may vary. Plus, I have no idea if IBM MobileFirst supports library projects.
Android studio create .jar file instead of .aar file
You can directly generate jar file using android studio. Here is a good tutorial for this.
Related Topics
Simple Way to Find If Two Different Lists Contain Exactly the Same Elements
Break When Exception Is Thrown
Eclipse Returns Error Message "Java Was Started But Returned Exit Code = 1"
Inetaddress.Getlocalhost() Throws Unknownhostexception
Jtable How to Refresh Table Model After Insert Delete or Update the Data
Compile Code Fully in Memory with Javax.Tools.Javacompiler
Field Required a Bean of Type That Could Not Be Found.' Error Spring Restful API Using Mongodb
How to Add Hyperlink in Jlabel
Double Checked Locking in Singleton
Determine Which Jar File a Class Is From
How to Create an Array of Arraylists
How to Make Threadpoolexecutor's Submit() Method Block If It Is Saturated
Converting Long to Date in Java Returns 1970
Spring Aop Not Working for Method Call Inside Another Method