Create library projects and reference for Android Studio
Android Studio creates a library project by creating a Module under the main project. When this Module is created, select the library project mode.
Why? In Android Studio, a WorkSpace is a main Android project. The main project is actually a Module of the workspace, but this Module is a main Module. If you want to create a Library project, it should also be a module project. Set it to Library.
The automatically generated build. gradle file contains a line of labels.
Apply plugin: 'com. android. library'
This line is different from the normal Module project. The normal Module project is
Apply plugin: 'com. android. application'
After a library Module Project is created, a module Module is added to settings. gradle under Project structure.
Include ': app',': mylibrary'
A library Module project has been created.
How can other Module projects reference this newly created library project?
Find the build. gradle file in the Module of the library project to be referenced, and add the following
Dependencies {
Compile project (': mylibrary ')
.......
}
Then, the Reference Library project is successful. You can test to reference the resources of the sub-database project.
Sometimes we need to reference many library projects under a project, and then we want to classify the library projects. We can create folders and put different types of projects under different folders. How can I reference a library project in this case?
In fact, it is very simple. You only need to modify the include ': app',': libs: mylibrary 'in settings. gradle'
Dependencies {
Compile project (': libs: mylibrary ')
.......
}
Here we assume that the new folder is libs.
The record is very simple, but it is amazing for a little white as, haha!
Wait for updates ......