(reprint) How Android studio generates AAR packages

Source: Internet
Author: User

 how Android studio generates AAR packagesTags: how Android studio generates aaandroid studio aarandroid How to build an AAR package2016-12-21 14:42 1856 people read comments (0) favorite reports Classification:Android Development ($)

When you build on one of your own libraries in Android studio, both the. jar and the. aar file are generated.

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:

1.aar package is an AAR file generated by SRC, Res, and Lib in Android studio under the packaging of Android, and after the AAR package is imported into other Android studio projects, other projects can be easily referenced by source code and resource files.

2. To generate the AAR package step:

①. Open a project with Android studio, then create a new module, select the Android Library when you create the module, and follow the new normal project operation

②. After the new module type is Android Library as shown

③. After the code is written in the new module, the AAR package is automatically generated after the entire project is compiled, and the path of the package is in the new module = = "Build = = =" Outputs ==>aar directory.

3. Other Androidstudio Projects Reference AAR package

①. Copying the AAR package to the Lib directory

②. Configuring the Build.gradle file:

Join

repositories {
Flatdir {
Dirs ' Libs '
}

Compile (name: ' camerascan-1.0 ', ext: ' AAR ')

Complete configuration file:

[Java]View Plain Copy
  1. Apply plugin: ' com.android.application '
  2. Android {
  3. Compilesdkversion
  4. Buildtoolsversion "22.0.1"
  5. Defaultconfig {
  6. ApplicationID "Com.geenk.testcamerascanarr"
  7. Minsdkversion
  8. Targetsdkversion
  9. Versioncode 1
  10. Versionname "1.0"
  11. }
  12. Buildtypes {
  13. Release {
  14. Minifyenabled false
  15. Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '
  16. }
  17. }
  18. repositories {
  19. Flatdir {
  20. dirs ' Libs '
  21. }
  22. }
  23. }
  24. dependencies {
  25. Compile Filetree (dir: ' Libs ', include: [' *.jar '])
  26. Compile (name:' camerascan-1.0 ', ext:' aar ')
  27. Compile ' com.android.support:appcompat-v7:22.2.0 '
  28. }
③. Compiling a project

Copy AAR package to Lib

After the diagram is copied to LIB, click the button to make the AAR package available for reference in the code, or to compile the project once

After successful operation, you can see the referenced AAR package file under the expansion package.

Top
1
Step
0
    • Previous custom material design style ProgressDialog
    • Next Android JNI package so file to apk
Related articles recommended
    • ? Android Studio Imports local AAR and jar packages
    • ? "Live" machine learning & Data Mining 7 weeks training--Wei Chi
    • ? Android Studio generates AAR packages and references (imports) AAR packages in other projects
    • ? "Live" large and medium-sized UGC information site SEO Sharing--Choshangyang
    • ? *.aar Package in Android Studio
    • ? "Live" to get through Linux context processes, threads, and schedules-Song Baohua
    • ? Axis2 code generation and hit AAR package eclipse plugin
    • ? "Package" Java Advanced Programmer Professional Learning route-Xiaohaipeng
    • ? Generate a jar package for a module in Android studio, and think it's okay to use AAR directly
    • ? "Course" basic of C + + language------Li Jian
    • ? Android Studio Build AAR package, jar package
    • ? "Curriculum" deep learning Foundation and TensorFlow practice--ai100
    • ? How Android studio relies on AAR project packages
    • ? Android-support-percent.aar
    • ? Android Studio 2.3 Dozen AAR packs
    • ? Android Studio and Eclipse generate jar packages separately and confuse Jar package demo
View Comments
No Comments

You are not logged in, please [login] or [register]* above the user's comments on behalf of their personal views, does not represent the views or position of the CSDN website

(reprint) How Android studio generates AAR packages

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.