Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you import an Eclipse project into Android Studio now?

Using "Import Project" in Android Studio for an Eclipse project used to change the project structure and generate Gradle files, but right now (I'm using AS 0.5.3) it's only generating IDEA files (.iml, .idea) but not Gradle and it's not touching the file structure either.

How do you import an Eclipse project into Android Studio now?

Update: Trying to export gradle files in Eclipse won't export them for the app, it doesn't show up as a module in Android Studio either.

like image 996
Phazor Avatar asked Apr 01 '14 16:04

Phazor


People also ask

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 import library to Android?

To use your Android library's code in another app module, proceed as follows: Navigate to File > Project Structure > Dependencies. In the Declared Dependencies tab, click and select Library Dependency in the dropdown. In the Add Library Dependency dialog, use the search box to find the library to add.


1 Answers

In newer versions of Android Studio, the best way to bring in an Eclipse/ADT (Android Development Tool) project is to import it directly into Android Studio; we used to recommend you export it from Eclipse to Gradle first, but we haven't been updating ADT often enough to keep pace with Android Studio.

In any event, if you choose "Import Project" from the File menu or from the Welcome screen when you launch Android Studio, it should take you through a specialized wizard that will prompt you that it intends to copy the files into a new directory structure instead of importing them in-place, and it will offer to fix up some common things like converting dependencies into Maven-style includes and such.

It doesn't seem like you're getting this specialized flow. I think it may not be recognizing your imported project as an ADT project, and it's defaulting to the old built-into-IntelliJ behavior which doesn't know about Gradle. To get the specialized import working, the following must be true:

  • The root directory of the project you import must have an AndroidManifest.xml file.
  • Either:
    • The root directory must contain the .project and .classpath files from Eclipse
  • or
    • The root directory must contain res and src directories.

If your project is complex, perhaps you're not pointing it as the root directory it wants to see for the import to succeed.

like image 87
Scott Barta Avatar answered Oct 13 '22 21:10

Scott Barta