Generating AAR file in Android studio and using AAR file locally

It mainly explains how to generate AAR files in Android studio and how to use AAR files locally. The details are as follows:

When you generate your own library in Android studio, you will generate *. Jar and *. AAR files at the same time.

Separate storage locations:

*. jar: Library / build / intermediates / bundles / debug (release) / classes.jar

*. AAR: Library / build / outputs / AAR / libraryname.aar

Differences between the two:

*. jar: it only contains class files and manifest files, not resource files, such as pictures and all files in res.

*. AAR: contains all resources. Class and res resource files contain all resources

If you are just a simple class library, you can use the generated *. Jar file; If your is a UI library that contains some control layout files and font and other resource files written by yourself, you can only use *. AAR files.

Usage:

*. jar: copy it to the LIBS directory, and eclipse can import it directly. Add the following to the androidstudio project:

Recompile the project once to complete the loading.

*. AAR: there are two methods: local loading and network loading. Since network loading involves publishing to Maven central for hosting, it will not be discussed here; In addition, eclipse has not been used for a long time and is not discussed; Here to tell you a local loading method, simple and fast.

The AAR file shown here is: "genius. AAR"“

Step 1: copy to LIBS directory

Step 2: change the build.gradle configuration file to

Add "repositories" and change "dependencies" respectively, and then recompile the project for normal use.

At this time, open your project address "\ build \ intermediates \ expanded AAR \" and you will find that there is an additional folder "genius". After opening, you can see that it contains a "classes. Jar" file, some resource files and "r.txt" files.

This is what happens when Android studio automatically parses the AAR file.

summary

The above is the method of generating AAR files in Android studio and using AAR files locally introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>