It mainly explains how to generate AAR files in Android Studio and how to use AAR files locally. *.jar and *.aar files are generated at the same time as build operations on one of your own libraries in Android studio. Store location separately:
*.jar: library/build/intermediates/bundles/debug (release)/classes.jar
*.aar: library/build/outputs/aar/libraryname.aar
The difference between the two:
*.jar: Contains only the class file and the manifest file, does not contain the resource file, the slice and so on all res files.
*.aar: Contains all resources, class, and res resource files all contain
If you are just a simple class library then use the generated *.jar file, and if you are a UI library that contains some resource files such as your own control layout files and fonts, you can only use the *.aar file.
How to use:
*.jar: Copy to: Libs directory, Eclipse import directly, add in Androidstudio project:
[Java]View PlainCopy
- dependencies {
- Compile Filetree (include: [' *.jar '], dir: ' Libs ')
- }
Recompiling a project can finish loading.
*.aar: There are two ways, local loading and network loading, because the network loading involves publishing to the mavencentral hosting issue is not discussed here, and Eclipse has not been used for a long time and does not discuss; Here's a quick and easy way to tell you a local load.
The AAR file shown here is: "Genius.aar"
First step: Copy to: Libs directory
Step Two: Change the Build.gradle configuration file to
[Java]View PlainCopy
- repositories {
- Flatdir {
- dirs ' Libs '
- }
- }
- dependencies {
- Compile (name:' Genius ', ext:' aar ')
- }
Add "repositories" separately and change the "dependencies", and then recompile the project once you can use it normally.
At this point, open your project address "\build\intermediates\exploded-aar\" you will find the following a folder "genius" open can see the inside contains a "Classes.jar" file with some resource files and "R.txt" File.
This is what happens when Android Studio automatically parses the Aar file.
[Android] [Android Studio] *.jar and *.aar's Build and *.aar Import Project method