Migrating from Eclipse to Android Studio

All our Android templates now support both Android Studio and Android Studio. But over the last couple of months, I have noticed more people asking how they should go about moving their existing Android projects from the Android Studio environment to Android Studio the InteliJ based IDE that is now the official editor for the Android project. As such I have decided to document the process of migrating a project from Android Studio to Android Studio.

A couple of things to take into account when migrating to is that Android Studio introduces a new project structure and build system. You will also need to keep in mind any third-party plugins you are using in your Eclipse project, these might require that you find equivalent plugins within the Android Studio environment

There are two methods for importing Android Studio projects into Android Studio, the first would be importing the Eclipse project directly into Android Studio using the import wizard, or exporting a the Eclipse project to a Gradle project and then importing the Gradle project. I will walk through both methods in this post.

To import an Android Studio project into Android Studio:

1) Start Android Studio, close any projects that you might have open.


2) From the menu select File New Import Project.

This can also be done from the Welcome Screen by selecting Import project (Android Studio, Gradle, etc.).

3) Select the Eclipse project folder of your existing project, and click Ok.

Android Studio - Select Project Folder Page

 4) Select a destination project folder, and click Next.

Android Studio - Select Project Folder

5) Select import options, and click Finish.

Android Studio - Import Options

6) Once the import completes Android Studio will show the newly imported project, with a project review summary.

Android - Project View

7) Validating the imported project.

After the completion of the import use the Build > Make Project  to build the project, and then use Run Run to execute your project. 

To import an Android Studio project into Android Studio using a Gradle build file:

Note this is for advanced users only, and I would recommend that this is only done if you have previous experience with the Gradle build system.


One pre-requisite for this process it to ensure your existing project builds completely as the wizard will not export a project that has errors.

1) Open Eclipse and then open the project you want to migrate

2) From the menu select File > Export

3) Within the Export wizard expand the Android folder and select Generate Gradle build files

Eclipse - Export Project

4) Select all the project you want to include in the export, click Next

Eclipse - Gradle Select Files

 5) Validate the selected projects, click Finish

Eclipse - Gradle Selection Confirmation

6) Note down the location of the gradle.build file, on the Summary page, and click Finish again.

Eclipse - Gradle Summary 

7) Start Android Studio, close any projects that you might have open.

8) From the menu select File > New > Import Project.

    This can also be done from the Welcome Screen by selecting Import project (Android Studio, Gradle, etc.).

9) Select the above-generated build.gradle file of your existing project, and click Ok.

Android Studio - Import Gradle

10) Once the import completes Android Studio will show the newly imported project, with a project review summary.

Android Studio - Project View

11) Validating the imported project.

After the completion of the import use the Build > Make Project  to build the project, and then use Run > Run to execute your project. 

Conclusion

This is a short introduction to migrating existing Android Studio Android projects to Android Studio. With the up and coming Android Studio 2.0 release, I believe now is the ideal time to start moving your existing Eclipse projects to Android Studio.

References

BY : Johan Van Zilj | CATEGORY : News |CATEGORY SLUG: news | Date : 22 January, 2016 | Tags :