Android Studio Create library projects and references

Source: Internet
Author: User

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

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.