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).

  • Fragment design: Adapting to multiple screen layouts by showing/hiding fragments within a single Activity?
  • How to use an existing database with an Android application
  • How to animate a View with Translate Animation in Android
  • android user agent
  • How to enable automatic shortcut creation after app downloads and installs from Android Market?
  • Android error in eclipse: Unable to resolve target 'android-xx'
  • 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?

  • List of Open Source projects that aid Android app development
  • Intercept and override HTTP requests from WebView
  • How to style the Google Play Services error on Android
  • Android: why must use getBaseContext() instead of this
  • Pinch to zoom with Osmdroid
  • Build Unsigned APK with Gradle
  • 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.