[Android Studio] *. jar and *. aar generation and *. aar import Project Method
This section describes how to generate an aar file in Android Studio and use the aar file locally. *. Jar and *. aar files are generated at the same time when you generate a self-built library in Android Studio. Storage locations:
Differences:
*. Jar: contains only class files and list files, excluding resource files, files, and other res files.
*. Aar: contains all resources, and all class and res resource files.
If you are just a simple class library, use the generated *. jar file. If you use a UI library that contains some control layout files and font and other resource files written by yourself, you can only use *. aar file.
Usage:
*. Jar: copy the file to the: libs directory. You can directly import the file to eclipse. Add the following to the AndroidStudio project:
?
1 2 3 |
Dependencies {compile fileTree (include: ['*. jar'], dir: 'libs ')} |
Re-compile a project to complete the loading.
*. Aar: There are two methods: Local Loading and network loading. Since network loading involves publishing to mavenCentral hosting, we will not discuss it here. In addition, we will not discuss it if eclipse has not been used for a long time; this is a simple and fast local loading method.
The aar file demonstrated here is: "genius. aar"
Step 1: Copy to: libs directory
Step 2: change
?
1 2 3 4 5 6 7 8 |
Repositories {flatDir {dirs 'libs'} dependencies {compile (name: 'genius ', ext: 'aar ')} |
Added "repositories" and changed "dependencies" respectively, and re-compiled the project to work properly.
Upload "file.
This is what Android Studio automatically parses the aar file.