0

Inside some aar archives their is a libs subfolder with some .jar in it. What the purpose of those jars? why they are not merged in the classes.jar? If I add the aar as a dependency of my android project, how the jar inside the libs subfolder will be included in the final apk?

1
  • I've never seen that myself but I guess those are dynamically linked JARs, loaded at runtime. If so they will be included the same way in the apk.
    – m0skit0
    Nov 21, 2022 at 23:19

1 Answer 1

1

The JARs in the libs directory of an AAR are dynamically linked during runtime. Exactly like the JAR files you would provide in the libs directory of your project.

As you may note, the content of an AAR file is similar to the structure of an Android application project -- at minimum a manifest file, and further (optional) files and directories. You may find resources (res and/or assets), libraries (native ones in lib, JARs in libs) and so on. Not every AAR files does even contain a classes.jar, as some of theme are only intended to deliver additional res content. That can often be found in compat-AARs.

Basically, during the APK building process one simple thing is made with an AAR file which has been included into the project. It will be unzipped and its files and directories are merged -- at least logically, not necessarily physically -- with their corresponding counterparts in the project. So in your case, the JAR files in the AAR's libs directory are added to the libs directory of your project, where you keep the Java libraries you want to link dynamically during application runtime.

Apart from that the APK building process runs as usual.

In short -- An AAR is a ZIP whose content is merged into the project it was added to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.