[Android] [Android Studio] *.jar and *.aar's Build and *.aar Import Project method

Source: Internet
Author: User

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
    1. dependencies {
    2. Compile Filetree (include: [' *.jar '], dir: ' Libs ')
    3. }

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
    1. repositories {
    2. Flatdir {
    3. dirs ' Libs '
    4. }
    5. }
    6. dependencies {
    7. Compile (name:' Genius ', ext:' aar ')
    8. }

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.