The creation of the library project in Android Studio is actually created by creating module modules under the main project, which selects the Library project mode when the module is created.
Why do we have to deal with it? Because a workspace workspace in Android Studio is an Android master project. The main project is actually a module in this workspace, except that this module is a master module. If you want to create a library project, it is obvious that it should be a module project, set up as a library.
Then the auto-generated Build.gradle file will be marked with a line.
Apply plugin: ' Com.android.library '
This line is distinguished from the normal module project, and the normal module project is
Apply plugin: ' Com.android.application '
After a library module project has been created successfully, there will be a module in the Settings.gradle in project structure
Include ': App ', ': MyLibrary '
Such a library module project is already created.
How do I get other module projects to refer to this newly created library project?
Locate the Build.gradle file in the module that needs to reference the library item, and add the following
dependencies {
Compile project (': MyLibrary ')
.......
}
Then again, the Reference Library project was successful. You can test the resources under the Library project under reference.
Sometimes we need to refer to a number of library projects under a project, and then the library project wants to categorize, you can create folders, and then put different types of items into different folders. How do you cite library projects in this situation?
Actually very simple, just need to modify the include ': App ' in Settings.gradle, ': Libs:mylibrary '
dependencies {
Compile project (': Libs:mylibrary ')
.......
}
This assumes that the newly created folder is Libs.
Recorded, although very simple operation but for a as small white also feel very magical, haha!
Have time to update ...
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Android Studio Create library projects and references