Generate references in Android studio AAR and Jar method details

*. Will be generated at the same time when you generate your own library in Android studio Jar and * AAR file.

Separate storage locations:

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

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

. Jar and AAR difference

In terms of name, one is java application resource; One is Android application resource;

All the differences can be realized from the name:

. Jar contains only class files and manifest files

. AAR contains class files and all other resource files, including resource files in res

For example, your lib library is a custom view package, which contains not only class files but also resource files. At this time, you need to add this library to In the form of AAR.

How to generate in Android studio aar . jar

In studio, it is managed by a moudel. Create a new moudel and select Android library

Then, after the code is completed, compile the moudel to generate it AAR and jar

You can use AAR if it contains resource files according to the role of your class library

How to reference in Android studio aar . jar

quote. jar

Add * Copy the jar to Lib in the app

Change build Gradle profile

It will be generated automatically in the new version of studio, so you only need to copy it directly Jar can be compiled in the Lib directory.

Reference local aar

Add * Copy AAR to Lib in app

Change build Gradle profile

It should be noted that if third-party LIBS are also referenced in the AAR, these third-party libraries are not added to the AAR after packaging, so they need to be referenced in the app In addition to AAR, you should also refer to other third-party libraries.

summary

The above is the whole content of this article. I hope the content of this article can help you learn to use Android studio. If you have any questions, you can leave a message.

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
分享
二维码
< <上一篇
下一篇>>