12

I have an android app codes in eclipse project stored in git server, and I want to import it into Android Studio.

Is there a way to retrieve the project from git directly into Android Studio? Is there a step-by-step instruction to achieve this?

Sean Lee
  • 363
  • 2
  • 5
  • 15
  • The same user answers both questions, but the follow-up comments, each has its own merit towards our use. For those looking for answers on this specific subject, make sure to review the comments below before disregarding it as duplicate. – Sean Lee Feb 21 '15 at 22:28

3 Answers3

20

Here is the step by step solution to do it. You can use your eclipse code directory for it.

  1. Open Android Studio -> Import Project-> Select your project directory. (In above case "MyApp") Remember Select the directory which contains Manifest file otherwise new "direct import wizard" doesn't get triggered and android studio uses old import wizard.
  2. Android Studio will create a copy of your project "MyApp_imported" with new directory structure.
  3. Copy your existing ".git" directory inside "MyApp_imported"
  4. Android Studio -> VCS -> Enable version control This will make Android Studio use your existing repository for imported project. Though imported project has different directory structure but git handles them pretty well.
  5. Android Studio -> Changes Review all files and commit. Git will automatically handle new directory structure and file history etc will not be lost.
  6. Now you can share it on github/Bitbucket by VCS-> Share it on GitHUb Note:- For bitbucket you will have to install "following Bitbucket plugin" for Android Studio. http://plugins.jetbrains.com/plugin/6207?pr=androidstudio

Here are more details about it: Import an eclipse android project with version control system into Android Studio

Community
  • 1
  • 1
Shakti Malik
  • 2,335
  • 25
  • 32
  • You saved me tons of hours with this explanation, thanks!! – Oded Regev Dec 02 '14 at 09:57
  • 1
    I can't find the Changes Review all files option in Android Studio 1.0.1 – Garro88 Dec 20 '14 at 13:29
  • @Garro88 Check Tab named "Changes" on left bottom of Android Studio – Shakti Malik Dec 20 '14 at 19:15
  • @ShaktiMalik ok I have found the tab, but now i have to commit all change or i have to do some operations? Soory but i am an Android Studio/Git noob =) – Garro88 Dec 21 '14 at 12:16
  • As explained above, Review files and commit. Note that you may want to ignore some file such as build and gen directory etc. – Shakti Malik Dec 22 '14 at 09:18
  • I found the bitbucket plugin referenced here is out of date. You can find the most recent plugin https://bitbucket.org/atlassian/jetbrains-bitbucket-connector/downloads – bitrock Feb 02 '15 at 02:36
  • what should i do to lots of changes appear from git status?? – user2273146 Feb 12 '15 at 09:13
  • @user2273146 Check-in all of those changes. – Shakti Malik Mar 03 '15 at 10:40
  • I have not tried this yet, but if the directory structure is different then I can't see how you could go back to a version of your app that *preceded* the move from Eclipse to Android Studio. And if you can't go back, then what is the advantage of using this approach rather than just starting over with a fresh git archive? – Carl Mar 11 '16 at 12:24
2

Couple of months ago I got my job as android developer.The first problem i had faced were my collegues who using Eclipse.I was allowed to use Android studio if I will not make any changes to existing project structure.After 3-4 attemps I finally found a decision.Here is steps to open Eclipse git project without migrating to Gradle and without changing project structure.

  1. Clone git repository of project
  2. Add /gen and /.idea to .gitignore
  3. Open any of already created Android Studio projects.
  4. File -> Open -> Choose path root project folder(with src and res inside)
  5. Doble-click project to open project structure
  6. Select root project folder -> F4
  7. Project -> Project SDK -> Android API XX Platform && Project language level -> Override in interfaces
  8. Modules -> Sources tab. Mark src as Sources && res as Resources.
  9. Modules -> Paths tab. Use module compile output path.Create folders output and output_test inside gen folder (create gen if folder not exist yet).Output paths should look like C:\Users\User\project_rep\project\gen\output
  10. Modules -> Dependencies tab. Click "+" -> Jars or directories.Select all .jar libraries which are using by your project.(Android Studio can pretend like its added only one jar but thats not true)
  11. Facets -> "+" -> Android
  12. Facets -> Structure tab -> Reset to defaults.
  13. Close Project Structure window.
  14. Run -> Edit configurations -> Android Application -> Module -> Select your module.Target device -> Show chooser dialog.

Finally, after all of those steps you are able to hit Run button.Enjoy!

Alexander Zar
  • 325
  • 3
  • 14
0

You can start checking if this tutorial can help, after enabling Git in Android Studio:

http://user-image.logdown.io/user/756/blog/753/post/159805/aW22jGw0QgO4H5wlqRBd_git%20tool%20test.PNG

If you then import into Android Studio your Eclipse project (already in a cloned git repo), you should see the Git options available for your project files.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The import part is quite straight forward, the unknown part is migrating from eclipse project into Android Studio within Android Studio. From Ant build to Gradle build, or anyway to support Ant build inside. I was asking for the whole enchilada. – Sean Lee Jun 30 '14 at 00:56
  • @SeanLee I faced exact same issue and i solved it. I have written a step by step solution for it as an answer above. Please let me know if you have some doubts – Shakti Malik Jul 15 '14 at 07:22