Code reuse in the android project in eclipse

Source: Internet
Author: User
Introduction

During development, there are usually multiple projectsCodeIn this case, the common practice is to set project dependencies so that one project can reference another project, for example, in Visual Studio.

In the android project of Eclipse, If You Want To reference another project, a similar method should be used theoretically:

Here is a reference project named core.

In this case, no problem occurs during code writing, but the noclassdeffounderror exception occurs when running the simulator because the class in the referenced project cannot be found.

In this window, you can add references using various functions in the libraries tab. The result is usually either compilation failure or the same as above.

I searched the internet for a long time and found that many people encountered this problem ~

 

Create a JAR File

It seems that eclipse cannot automatically implement project integration. Therefore, you can only consider outputting public projects as jar before importing the required projects.

Because my public project is not a general Android project, I only want it to act as a public class library and provide some general functions, therefore, I created this project as a common Java project, removed the Java-se reference from libraries, and added android. jar. JAR file), and then execute export:

Select the JAR file type:

Next, set the Save path here:

Next, go to the next step. Here you can use the default settings to generate the manifest file, or you can set the specified file by yourself:

The export is complete.

 

Import jar files

Now you need to import the previously exported JAR file in the project to be used. You only need to add external jars... Function select the previously exported JAR file:

 

References

Http://blog.csdn.net/guanmjie/archive/2009/08/12/4437779.aspx

Http://hi.baidu.com/gaogaf/blog/item/1757d309274b098cd1581bd7.html

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.