How to import an existing Android Library project

2019-09-01 01:02发布

问题:

I see there are powerful support projects out there like this one: https://github.com/JakeWharton/Android-ViewPagerIndicator

All the tutorials and posts I have found describe:

  • what an Android Library Project is
  • how to create one from scratch
  • how to reference one after it's already in your Eclipse workspace

But I haven't found the correct steps for how to do an import into eclipse for such a project.

I have tried to create an empty Android library project and then copy over the files; and then also tried to link to the library project root folder in the eclipse project config for another empty project. Those didn't work.

So my question is .. what's the correct way to import the ViewPagerIndicator project into my Eclipse workspace?

Thanks

回答1:

Right click on Workspace - > Import -> Existing Android Code Into Workspace -> Library Folder

Note:

To avoid other inconveniences, do this:

1) Once is already in your Workspace, make sure that the project is marked as "Library." Right click on Library -> properties -> Android -> Check Is Library

2) At the time of importing, change the name of the folder. Please, specify something different than just "library". Projects on github usually come that way.

3) Make sure that every file is in the folder. For instance, Eclipse won't import anything if project.properties is not inside the Library folder. In a similar situation, Eclipse could import the project, but it would not create the R.java file if something is missing or there are errors in the layouts of the library.

4) Make sure that all dependencies match with your project. For instance, if certain library needs android-support-v4.jar, make sure that both (project and library) share the same version of the file. Once again properties -> Java Build Path -> Libraries -> Add or remove Jars

5) To make your project dependent of the imported library, Right Click on the project -> properties -> Android -> scroll until the end and add the imported library.