Explain the Android. AAR file generation method and usage skills in detail

Whether you use eclipse or Android studio for Android development, you will contact the jar package. The full name should be: Java archive, that is, Java archive. In the process of using as, you will find that AAR is an Android archive. I think its full name should be Android archive.

What's the difference between them?

Personal understanding:

Jar is a compressed package of class files compiled from java files.

AAR is the total compressed package of all resource files and compiled Java files in Android module.

The difference is that AAR contains not only the class file, but also the resource file.

How to import AAR files in Android studio?

Take the AAR file of recyclerview as an example.

1. AAR file found:. \ Android_ SDK_ Windows \ extras \ Android \ m2repository \ com \ Android \ support \ recyclerview-v7 \ 24.0.0 \ recyclerview-v7-24.0.0.aar copy to LIBS directory in Android studio project.

2. Then enter the following in the build.gradle file of the module corresponding to Android Studio:

3. Then rebuild the whole project.

How to export a module as an AAR file in Android studio?

Take testlibrary as an example:

1. Execute the assemblyrelease command of the corresponding module:

Remember from the above figure that if it is the main module of the project, i.e. app, the APK package is generated.

2. In the build \ outputs \ AAR \ directory of the corresponding module:

What if you want to import the AAR file into eclipse?

As shown in the figure: after opening the AAR file with WinRAR and other compression software, you will find that it is the above structure. Classes.jar is the jar package of class file, and others are Android related resource files.

If you want to import into eclipse, you need to convert all the resources and class files into a library project.

Create a new library project with eclipse, import res resources, manifest files and publish compiled Java files.

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