How to create new android project in eclipse and share in local git repository?

I use the wizard to create a new Android project in Eclipse Juno with Android SDK Tools revision 20.0.3 at build SDK 15 and minimum required SDK 15. The files are generated with sample code for activity, manifest, etc. I have tried different templates (like MasterDetail or BlankActivity with Tabs) in this process and there are sometimes issues such as AndroidManifest.xml or activity_main.xml with repeated XML elements. So I fix these issues manually (which I think is a bug with the wizard).

Now, I want to “team share” the project via EGIT. So I right-click the project and “Team->Share Project->git”. At this point, it wants me to choose a repository. I have created a new one outside Eclipse workspace (and re-used it once created). (I also tried creating one in the parent directory (i.e. in workspace despite an Eclipse warning not to do so).

  • Bonjour implementation on Android
  • Poor performance of Android Canvas.drawBitmap - switch to OpenGL?
  • Android: How to create a Dialog without a title?
  • Google Maps Android api v2 and current location
  • The APK file does not exist on disk
  • Problems importing project into Android Studio regarding ActionBarSherlock
  • Either way, when the share operation completes, the buildpath for Libraries “Android Dependencies” does not have the “android-support-v4.jar” in the location specified which was in the workspace. It seems that after the egit operation, the project directory appears to have been moved to the repository, but the .classpath file has not changed.

    Is this how egit should work (move project workspace inside git repo and tell Eclipse that the project directory is in a new location)? Is the only workaround to fix the buildpath manually?

    Is there a different approach to create new android project in Eclipse and then put the relevant files (i.e. exclude generated java files) into a local git repository such that Eclipse EGIT works?

    Related posts:

    Google Api Client sometime NULL in onConnected
    What is the integer value that gives a broadcast receiver highest priority?
    Removing AppWidgets programmatically
    How to properly initialize and terminate EGL on Android
    overridePendingTransition not working
    How did they make such layout - which elements they used?
  • NetworkOnMainThread
  • Upgrade to Google Play Services:9.0.0 Error Failed to resolve: com.google.android.gms:play-services-measurement:9.0.0
  • Android PDF Viewer Library or muPDF library tutorials
  • Android ActionBar's custom view not filling parent
  • Play mp3 sounds from SD card
  • Android: application dies unexpectedly, leaving me clueless to the reason
  • One Solution collect form web for “How to create new android project in eclipse and share in local git repository?”

    I am answering my own question after some trial and error.

    Here are the steps.

    1. Create the android project via the wizard.
    2. Fix any XML errors (as necessary) to get a buildable project.
    3. Right-click project and Team->Share Project->Git
    4. Select the Git Repository (and create if necessary).

    At this point, the Android Dependencies (a dynamic classpath container) in the Java Build Path will be wrong because Git has moved the files to the repository.

    1. Close the project (Project->Close Project)
    2. Re-open project (Project->Open Project)
      Now, the Android Dependencies are correct because it is dynamic. I don’t know the exact mechanism used by Eclipse for dynamic classpath container, but if you read the Android Tools website it will explain the rules used to to populate this container.
    3. Clean the project. (Project->Clean…)

    The important thing is not to try to fix these Android Dependencies yourself (like deleting it), because then your Android project may have issues when you start to build the APK.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.