Many novice friends and friends sometimes don't understand how to import eclipse when they search for open source projects on GitHub. Indeed, sometimes those projects only source code, to pack their own jar or connect the library to use, the novice friend is not to touch the mind. My simple summary is as follows:
First Category: Direct Project
This class is the simplest. As soon as you see it is an Android project source code.
Example: See Snow Forum Https://github.com/kanxue-team/kanxue-android-app
Operation: You can directly download, unzip, directly import into eclipse can be compiled and run.
Class II: Library and Demo Code fit
This class is usually a widget of the project source (structure 1), in the file list, you can generally see two folders, one is the library, one is demo. Where the library is the source code for the component project, and the demo is just a simple demonstration of the code that uses the component.
Example: Pulltorefresh component Https://github.com/johannilsson/android-pulltorefresh
Figure 1
Operation:
① we take Pulltorefresh as an example, you can directly download, extract to a directory such as "E:.../Android-pulltorefresh-master", 1 can be seen, Pulltorefresh for the library, and Pulltorefreshexample is demo demo.
②eclipse Import the Android-pulltorefresh-master directory, note that when you import this directory, import two items Pulltorefresh and pulltorefreshexample are displayed, and all two of us have to tick import.
③ set Pulltorefresh as Library. Right-click the Pulltorefresh project? Click Properties--> click on the "Android"--right down screen in the left-hand corner to select the "Is Library" check box and click OK to finish.
④pulltorefreshexample project into the library. Under the Pulltorefreshexample project, open the Project.Properties file under the same directory as the Androidmanifest.xml.
Add a line: android.library.reference.1=. /pulltorefresh/
It is a directory that specifies a library to reference, with absolute and relative paths available, in this case "..." Represents the previous level of the current directory (both e:.../android-pulltorefresh-master directories), ".. /pulltorefresh/"is a catalogue of our PULLTOREFRESH projects.
Category III: Packaging JAR file Use
This class is usually a widget of the project source code, in the file list, generally only the project source, no demo code (used in the documentation) or the demo code can not be used directly. We need to package the source code ourselves as a jar file for our project to use. (Another good option is the library, which references the source code directly in your project, as in the fourth step of the second Class)
Example: Async-http component Https://github.com/loopj/android-async-http
Operation:
① you can directly download, unzip, import into eclipse directly. But notice that you are not able to run.
See the "Android.library=true" in the Project.Properties file, it's a library.
② package jar. JAR files can be typed in Eclipse's File->export->java->jar file. The dialog box that pops up is set up as follows:
Simply select the SRC and Assets folders, which are not selected by the side profile. The output file modifies the jar file. Click Finish.
③ your project into the jar package. Directly put the generated library.jar into "Libs", note that the jar,elipse in this directory is automatically configured, "Libs" directory name can not be changed, otherwise you need to manually configure.
GitHub Android Open source project compiled and run