Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Import an eclipse android project with version control system into Android Studio

Tags:

I am trying to import an eclipse project with version control system into Android Studio.

Support for direct eclipse project import was added in Android-Studio version "0.5.5" where we don't need to export project first from eclipse to import it into Android-Studio.

I have an eclipse Android Project which I am trying to import into Android Studio. Import is successful but imported project no more has version control.

Edit:- More detail

Suppose I have following Directory Structure

Project ----            |---------- .git/            |----------- MyApp             |------------MyApp_imported 

During project import, I point Android Studio to Project Directory "MyApp", It copies all files in my project "MyApp" to new directory "MyApp_Imported". But imported project doesn't have version control enabled. Now I am not sure how to proceed further. How should I tell Android Studio to use old repository for imported project. A step by step guide to do this will be very helpful .

Here is text from Android Tools Project Site

Project - Importing modules should now work properly. You can import existing Eclipse ADT projects as well as Gradle modules into an existing Gradle project; it will copy in the sources as is done for full project import, as well as handle dependencies transitively. Import modules either from the project structure dialog or the File | Import Module action. - New project structure dialog implementation: Should be faster, includes Gradle sync notification, should only perform a Gradle sync at the end when necessary, and won't list invalid IntelliJ module warnings as before.
This is actively being worked on and the individual editors (for flavors, build types, signing configurations etc) will be improved in upcoming builds.

like image 229
Shakti Malik Avatar asked Jul 13 '14 18:07

Shakti Malik


People also ask

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

How do I export and import an Android Studio project?

Then take the folder (in the workspace folder) of the project and copy it to a flash memory or whatever. Then when you get comfortable at home, copy this folder in the workspace folder you've already created, open the Android Studio and go to File then Open and import this project into your workspace.


1 Answers

Here is the step by step solution to do 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. You might want to also call git add . and git add -u in the root folder of the imported project to make sure all new files are added and existing file moves are detected by git.
  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 "Bitbucket plugin" for Android Studio.
like image 83
Shakti Malik Avatar answered Nov 01 '22 18:11

Shakti Malik