4

I want to import an existing android project into my workspace using Android Studio. I tried by the common method like File->Import project->Selected folder but the problem i am facing that the project is getting imported in to the same existing project whereas in eclipse i will be having an checkbox stating that Copy projects in to workspace(so that i can copy my projects easily by ticking the checkbox into my workspace). Since i am new to Android studio i couldn't able to trigger the hidden features to import and copy the projects in to workspace. Kindly help me by your valuable replies.

Note: currently i am copying the file from another location in to my workspace and then importing a project in to Android studio. But it is becoming tedious while handling multiple projects at a time

Chandru
  • 5,954
  • 11
  • 45
  • 85

4 Answers4

2

This is how usually to import projects to Android Studio desired workspace.

Android Studio 1.0.2

File ---> Import Project ---> (your current project folder) ---> Import Destination Directory (your workspace location) ---> Finish

Srikar Reddy
  • 3,650
  • 4
  • 36
  • 58
  • sorry its not showing any options like as you said. – Chandru Jan 12 '15 at 13:04
  • Which version of Android Studio were you using and what type of project (eclipse project) were you trying to import? – Srikar Reddy Jan 12 '15 at 13:37
  • yes eclipse project. eventhough its not working with android studio project. I am using Android studio 1.0.2 – Chandru Jan 13 '15 at 04:26
  • 1
    This only works when you are importing an Eclipse project. It doesn't happen when you are importing an Android Studio project (with gradle and everything) – ocramot Mar 16 '15 at 09:14
1

I am just having the same problem.

As it happens, if you have a complete AndroidStudio / gradle project and you want to import it in Android Studio, just copy (or move, which is faster) the entire folder in your workspace, and then Use File -> Open, instead of File -> Import Project.

It seems to be exactly the same for the IDE, I can "import" and build a project flawlessly, but of course the "import" is faster (I don't really know why it is working that way).

EDIT:

after looking closely at the "opened project" structure, I think Android Studio is doing something weird. I copied the project from directory A to directory B, and I'm opening the project on directory B, but some of the files are still pointing to directory A.

I retried copying the project in directory B and then importing the project from B, instead of opening; now the references seem correct.

ocramot
  • 1,361
  • 28
  • 55
  • That weird operation happening because android studio uses gradle system to build up the files. So it would even mention ur workspace history and track. Eventhough if u move to the new project workspace, the editor will automatically opens the files which are being opened from your older one. – Chandru Mar 17 '15 at 09:59
0

I solved my problem editing the file settings.gradle in the root:

include ':app', ':myAnotherModule'
project(':myAnotherModule').projectDir = new File('../my-another-project/myAnotherModule')

After run gradle sync, you can import this module inside build.gradle file:

dependencies {
  //...
  implementation project(':myAnotherModule')
  //...
}
Ângelo Polotto
  • 8,463
  • 2
  • 36
  • 37
-1

If you are trying to import a whole project to your workspace by creating a new application from existing code then that is very easy as long as project you are importing is on already on the folder of your workspace or there is no conflicting project on your workspace with the same name.

On the other hand if you have a project on your workspace that you are working on and you want to import other projects to it then it becomes challenging especially if you dont have a well define working sets. I suggest that you:

  1. Open particular folders of the project you want to import for instance the "src" folder and copy the java files in it directly to your project on your eclipse (If you are using it)
  2. Right click on the src file on your eclipse and paste the java files. It will save you the time of changing the package name on the java files.
  3. Do the same for the resources files by copy pasting them from the respective files to the corresponding files in your project.
  4. Then when you do this dont forget to edit the manifest file with the new changes of the activities you imported. To do this you need to look into the manifest of the project you were importing so that you do not miss a point.

It may appear tidious and cumbersome but it will help you know what exactly you imported. But you will need to change package names in the java files to the current package name.

Jack Siro
  • 677
  • 10
  • 29