Android project: details on how to reference another Android Project

Source: Internet
Author: User

Now we have an Android Project. We want to expand the function of A, but do not want to develop on the basis of A, So we created another Android Project B and wanted to reference A in B.

One idea is to make project A pure Jar package so that other projects can be referenced directly.

However, if the reference in R. java is used in project A, it cannot be packaged into A jar package. The reason is that R. java is automatically generated and dynamic, and each compilation is different. If you must make a jar package, you cannot use the automatically generated R file. When using resources, you need to write code to get it.

Another idea is to make project A an android library project.

Set Project A, right-click and choose Properties> Android, select the Is library item, and then Apply. Set Project B, right-click and choose Properties> Android. In the Library, click Add to Add Project A, and then Apply. In this case, resources and code in A are introduced in B, which can be called directly. It should be noted that, because A is no longer A complete Android Application, but A class library project, some content needs to be configured in B. For example, if A has A lib library reference, B must also add the lib library. For example, the AndroidManifest. xml file in A must be added to the AndroidManifest. xml file in B...

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.