GitHub Android open-source project compilation and running

Source: Internet
Author: User

Many new friends sometimes cannot understand how to import eclipse when searching for open-source projects on GitHub. Indeed, sometimes those projects only have the source code. If you want to package your own jar files or connect to the library, you will not be able to understand them. My summary is as follows:

Category 1: direct project

This type is the simplest. You can see the source code of an android project.
Example: see the snow Forum https://github.com/kanxue-team/kanxue-android-app
Operation: You can download, decompress, and import the package directly into eclipse to compile and run the package.

Class 2: library and demonstrationCodeFit

This type is generally the project source code (Structure 1) of a small component. In the file list, you can see two folders: library and demo. The library is the Source Code of the component project, while the demo is just a simple demo of using the component code.
example: pulltorefresh component https://github.com/johannilsson/android-pulltorefresh
Figure 1
operation:
① We use pulltorefresh as an example, you can download it directly, decompress the package to a directory such as "E :... /Android-pulltorefresh-master ", 1 it can be seen that pulltorefresh is the library, while pulltorefreshexample is the demo.
② eclipse imports the Android-pulltorefresh-Master Directory. Note that when importing this directory, the pulltorefresh and pulltorefreshexample of the two projects will be displayed. Check the import check box for both projects.
③ set pulltorefresh to library. Right-click the pulltorefresh project and choose Properties> android in the left-side Navigation Pane. Click the "is library" check box in the lower-right corner. Click OK.
④ import the pulltorefreshexample project to the library. Open the project. properties file in the same directory as androidmanifest. xml under the pulltorefreshexample project.
Add a row: Android. library. reference.1 = .. /pulltorefresh/
specifies the directory of the library to be referenced. The absolute and relative paths are available. In this example, ".. "indicates the upper level of the current directory (E :... /Android-pulltorefresh-Master Directory), "../pulltorefresh/" is the directory of our pulltorefresh project.

Category 3: Package jar files

This type is generally the project source code of a small component. In the file list, only the source code of the Project is generally used, no DEMO code (used in the instruction document) or the Demo code cannot be used directly. We need to package the source code into a jar file for our project. (Another good solution is library, which directly references the source code in your project as in step 4 of the second category)
Example: async-HTTP component https://github.com/loopj/android-async-http
Operation:
① You can download and decompress the package directly and import it to eclipse. But note that you cannot run it.
Do you see "android. Library = true" in the project. properties file? It is a library.
② Package jar. You can type a jar file in eclipse File> export> JAVA> JAR file. The pop-up dialog box is set as follows:
You only need to select the SRC and assets folders, which are not selected by the side configuration file. Modify the JAR file in the output file. Click Finish.
③ Import the jar package to your project. Put the generated library. Jar directly into "Libs". Note that Elipse will automatically configure the jar in this directory, and the "Libs" directory name cannot be changed. Otherwise, you need to manually configure it.

 

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.