Eclipse: How to import git project as library for Android Project which has to be pushed to Bitbucket
Sorry for the long title, here’s the jist:
- I have a android application project which I’m hosting on bitbucket.
- There is a library on github I’d like to add as a dependency.
I’m unsure of
- How to add the github project as a library to my Eclipse project?
- How this will work when pushing/pulling from Bitbucket?
2 Solutions collect form web for “Eclipse: How to import git project as library for Android Project which has to be pushed to Bitbucket”
Setting your dependency as a library: you’ll have to clone the project to a local folder, import it as a project into Eclipse, and in your project configuration you’ll have to set the library project as a library: do a right-click in the project’s name, go to Properties and under “Android” click in the checkbox “Is library”.
Adding the library to the main project: In your main project, go to project properties the same way, and under “Android” click in the “Add” button and add a reference to your library problem.
More details here: http://developer.android.com/tools/projects/projects-eclipse.html
git: if you don’t want to put the library’s source code into your project you can add it to a .gitignore file and download it manually everytime you clone your project from Bitbucket. You can also take a look at git submodules: http://git-scm.com/book/en/Git-Tools-Submodules . Sorry but I never used them to give you more details.
If the library is a
.jar file, you can simply paste it into the
libs folder of your app. Android should automatically add it to the build path. As far as pushing/pulling from BitBucket goes, as long as you add the
.jar file in
git the library will be committed like any other file.