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
- Apply plugin: ' com.android.application '
- Android {
- Compilesdkversion
- Buildtoolsversion "22.0.1"
- Defaultconfig {
- ApplicationID "Com.geenk.testcamerascanarr"
- Minsdkversion
- Targetsdkversion
- Versioncode 1
- Versionname "1.0"
- }
- Buildtypes {
- Release {
- Minifyenabled false
- Proguardfiles getdefaultproguardfile (' proguard-android.txt '), ' Proguard-rules.pro '
- }
- }
- repositories {
- Flatdir {
- dirs ' Libs '
- }
- }
- }
- dependencies {
- Compile Filetree (dir: ' Libs ', include: [' *.jar '])
- Compile (name:' camerascan-1.0 ', ext:' aar ')
- Compile ' com.android.support:appcompat-v7:22.2.0 '
- }
③. 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