12

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?

Paŭlo Ebermann
  • 73,284
  • 20
  • 146
  • 210
azgolfer
  • 15,087
  • 4
  • 49
  • 46
  • You current solution bears some resemblance with http://stackoverflow.com/questions/5091946/android-build-works-in-eclipse-but-not-with-ant-already-added – VonC Mar 25 '11 at 12:25
  • Are 1 and 2 different checkouts (modifying files in one doesn't affect the other)? Sounds like 1 is a clone of the remote and 2 is a submodule clone of the local. – idbrii Apr 02 '11 at 16:36
  • If you have two checkouts, you don't need to have the project itself in the workspace. You can add a submodule directly from a remote. – idbrii Apr 02 '11 at 16:57

1 Answers1

2

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.

idbrii
  • 10,975
  • 5
  • 66
  • 107
  • Thanks, it turns out EGit (Eclipse Git plugin) does not support submodules too well, so I have to look at other solutions. – azgolfer Apr 03 '11 at 04:18
  • I would not recommend using EGit - it is very half-baked and presents many problems especially in a large environment. – jjNford May 25 '12 at 17:17
  • 1
    I think the other solution that works very well is, the terminal :) – philipp Nov 15 '12 at 21:53
  • See also this question: http://stackoverflow.com/questions/302089/git-plugin-for-eclipse – idbrii Nov 16 '12 at 19:09