Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I setup my Git repositories for Android development in Eclipse?

I need some help with properly versioning my Android project with Git/Eclipse.
I have no problem setting this up with a single Android project.

However, I am trying to figure out the proper and correct way to set this up, if I add one or more third party Android libraries to my main project (e.g. Facebook SDK).

So currently I am using git-submodules to accomplish this, and here's my directory structure:

/project/android-main.git
   +--- /project/android-main/facebook-sdk

I added facebook-sdk as a git-submodule within my android-main project.
In Eclipse workspace's android-main project, I am seeing the subfolder 'facebook-sdk'.

Then here comes the kludge:
I have to import 'Existing project' from /project/android-main/facebook-sdk as a new project, so that I can reference this project as a library from my android-main project.

In the end, Eclipse workspace has three references to 'facebook-sdk':

  1. The project itself in the workspace.
  2. because I added it as a git-submodule, it showed up as a folder in android-main project.
  3. Another folder 'facebook_sdk_src' is created by the Android SDK plugin in android-main project.

This seems to clutter the workspace and the main project, if I add more submodules.
Am I doing it right?
Is there a better way to use Android Libraries as a submodule in Eclipse?

like image 312
azgolfer Avatar asked Mar 24 '11 18:03

azgolfer


People also ask

How do I connect to a repository in Eclipse?

If you have not previously created a repository connection, click the Create a Repository Connection link in the Team Artifacts view. Otherwise, right-click in the Team Artifacts view and click New > Jazz Repository Connection. In Create a Jazz Repository Connection window, enter a Location URI.

Where is Git repository in Eclipse?

Use Ctrl+3 (or Cmd+3) and type Git Repositories in the dialog to open the Git repositories view. This view shows you the Git repositories you can work with in Eclipse and allows you to add existing repositories to Eclipse, create or clone repositories. It also allows you to perform Git operations.

How do I know if EGit is installed in Eclipse?

Check to see if you have egit – go to "window"->"show view"->"other" and see if you have "Git". If you do, then you have egit already installed and you should go to Step 2.


1 Answers

All of my Android projects are at the same level. Eclipse displays each project twice: in the workspace (workspace/library) and inside projects that reference it (workspace/project/library_src).

You could try making both facebook-sdk and android-main submodules so that they're at the same level. Something like this:

/project/
   +--- android-main.git
   +--- android-project/
           +--- android-main/
           +--- facebook-sdk/

So create a bare repo for your android project (android-main.git). This repo doesn't need to be in your workspace. Then add a subfolder for your code (android-project) and add your submodules.

like image 72
idbrii Avatar answered Oct 20 '22 11:10

idbrii