Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import eclipse project from git to Android Studio? [duplicate]

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?

like image 551
Sean Lee Avatar asked Jun 28 '14 00:06

Sean Lee


People also ask

How do I clone a project from GitHub to Eclipse?

Open Eclipse and choose Import –> Projects from Git (with smart import) Choose the Clone URI option in the Git import wizard and click Next. Confirm the URI, Host and Repository path parameters and click Next. Choose the Git branches to clone from the remote repository and click Next.

Can I run Eclipse project in Android Studio?

Import as a project: Start Android Studio and close any open Android Studio projects. From the Android Studio menu click File > New > Import Project. Alternatively, from the Welcome screen, click Import project (Eclipse ADT, Gradle, etc.).

How do I import a project from one project to another in Android Studio?

Go to File->New->Import Module then browse you project. After importing module go to project structure and add module dependency to your project.


2 Answers

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

like image 160
Shakti Malik Avatar answered Oct 23 '22 13:10

Shakti Malik


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!

like image 36
Alexander Zar Avatar answered Oct 23 '22 12:10

Alexander Zar