Android: About master Engineering and library project

Source: Internet
Author: User

Reprinted from: http://blog.sina.com.cn/s/blog_a3b9b9040101lco3.html

On GitHub Download the Android Open source project Quick news source code, which used to the third party project framework Vitamio, after the download of the source code into the IDE, found that all references to Vitamio file will be error, in the unknown how to solve the problem, Go back to GitHub on the project page, look carefully at the project introduction, found this sentence description "Quicknews is a run project and Vitamio is a library project." and decided to search the library project. The meaning, found this article http://blog.sina.com.cn/s/blog_a3b9b9040101lco3.html, in its help, I resolved the above error, so reproduced for the future to encounter similar problems as a guide.

1, how to use an Android project as a library project (database project)

Library project was used as a jar package by other Android projects, and first it was also a normal Android project. And then:

1) in Eclipse package Explorer, right-click on Android project to select Properties

2) Select Android, pull the scroll bar to the bottom and select "Is Library"

3) Click Apply, click OK

This Android project became the Library project.

Note: As a library project can refer to the external jar package, but not to reference other library projects, in the library project cannot use the Aidl file, can not reference raw, assets resources

In addition, when attempting to run a library project, Eclipse will error:

2, how to cite the main project library project

When the Lib project is referenced, the main project can invoke the relevant classes and methods of the Library project. Android Project references other library engineering steps:

1) in Package Explorer, right-click on Android project to select Properties

2) Select Android, drop down to the right of the scroll bar to the bottom

3) Click the Add button to open the Lib Project selection dialog box

4) Select project from the selection dialog and click OK

5) Click the Apply button and click the OK button

3. Declare the components of the LIB project in the main project manifest.xml file

All activity, Service, receiver and provider of the library project must be added in the main project Manifest.xml, and the permission, uses-library and other attributes of the library project should be added. Note that the referenced component uses the full package name, otherwise the corresponding notfoundexception will be reported.

4. Conflict between library engineering and main engineering resources

When running an Android project referencing the library project, the Android tool will merge all the resources of the Library project with the master project. If a resource ID is likely to be defined between the library project or between the Library project and the master project, the resource ID with high priority will override the lower priority, and resources will be used with the most wired-level project. How the priority level between projects is determined, see the next article.

5. Priority issues between library projects and the use of resources in the main project

Shows an Android project referencing four library projects, which have priority points between the four library projects and the main project. Android master project has the highest priority, the four library engineering imperial Examinations ranked down to the next priority level. Library projects can also be manually sorted, select one, click Up (Increase priority) or down (lower priority).

6. Library Engineering and master engineering use different Android platform version issues

When the master project is packaged, the Android SDK version uses the main project. So the Android SDK version used by the library project is either higher than the main project SDK version. If the Library Engineering SDK version is higher than the main project, it will not compile.

Android: About master Engineering and library project

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.