(71) One project in Android referencing another project

Source: Internet
Author: User

Now that we have an Android project A, we want to expand the functionality of a, but do not want to build on the basis of a, and then create another Android project B to reference A in B. There are usually two ways to achieve this:

1, make the project a pure jar package

Right-click Project-->export--> tap java--->jar file--->Next--> tick src package, other items do not select-click Finish to generate the JAR file.

However, if a reference in R.java is used in project A, it cannot be hit as a jar package. The reason is that R.java is generated automatically and is dynamic, and each compilation is not the same. If you must make a jar package, you can not use the auto-generated R file, use the resources to write code to get.

2. Make project A into Android library project

Set up project A, right-->properties->android, select the IS library item, and apply. Set Project B, right-->properties->android, in the library, click the Add button to add a project, and then apply. The resources and code in A are introduced in B at this point, and these resources and code can be called directly. It is important to note that because a is no longer a complete Android application, it is a class library project, so there are some things that need to be configured in B. For example, a in the Lib library reference, B will also be added to the Lib library, such as the contents of the Androidmanifest.xml file in a, in the B androidmanifest.xml file should also be added ...

If you do not need to reference a project's resource files, you just have to get the jar file, set up project A, right-click->properties->android, select the IS library item, and apply. A jar file can be obtained from the bin directory of the A project, which is directly referenced in the Libs directory in Project B.

Reference from: http://blog.csdn.net/lixin88/article/details/8609575

(71) One project in Android referencing another project

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.