Android Studio Production library (graphic)

Source: Internet
Author: User

First, from the project right-click Add a new library.

The first step: to the Android directory, right-click->new->module.

Such as


Step Two:

Select Android Library, next


Enter the package name or something, finish


The third step: let the project compile the library, there are manually added or automatically added two ways. (In the last chapter, this chapter is a short one)

Add Manually:

Open Module:app's build.gradle, add a line to compile the new library, sync, complete.

Such as:


Add automatically:

Project structure->module->app-> the last card dependencies-> to the right of the plus sign, select the Module, select the newly created library, complete. Such as:



Second, change your existing project into a library.

Two ways of thinking:

1. Like above, create a new library configuration, copy your code java,res,libs, reconfigure the Gradle file. Copy, don't say, the programmer comes with CTRL + C and CTRL + V skills.


2. Remove unnecessary files from existing projects, and modify the configuration file to import. This method is self-groping, the following to share this method in detail.


The first step, see below is a prepared Android studio project, project named Canvasdemo. The deletion of the selected, these are not necessary.


In the second step, drag everything under the app directory to the root directory and delete the app's directory.


The third step, modify the configuration file, (1) The app.iml file renamed to the project consistent with the Canvasdemo.iml, and then use notepad++ Open the file, there are two places are : the app , Also change it to match the project name : Canvasdemo , save it.


Fourth step, open the build.gradle file with notepad++, to change two places, (1) Apply plugin: "Com.android.application" this sentence instead Apply plugin: "Com.android.library",(2) This sentence with the beginning of ApplicationID is deleted.


Fifth step, copy this canvasdemo to the root of the project


Sixth step, switch to the Android directory, open the Settings.gradle file, include here add a comma, plus ': Canvasdemo '. Here's why . The name of the. iML suffix is changed to match the name of the project, and some of the bands in the file : The app is changed to match the project name : Canvasdemo.


The seventh step, the final step is in the project with the Library's compilation, manual and automatic two ways above has been mentioned, you know, do not understand to look on it, detailed illustrations.


If you have not mastered the basic guide package, please read my previous article
Previous article, link http://blog.csdn.net/qq_29623203/article/details/51190242

Android Studio Production library (graphic)

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.