Android Studio generates AAR packages and references AAR packages in other projects

Source: Internet
Author: User

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 PlainCopy
  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.

Android Studio generates AAR packages and references AAR packages in other projects

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.