MobileAndroidMigrating From Eclipse to Android Studio

Migrating From Eclipse to Android Studio

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

Despite Android Studio’s ‘beta’ status, it’s still an IDE that’s worth exploring, even at this early stage. If you’re currently working on an Android project in Eclipse, you may be wondering whether you should finish this project first, before making the leap to Android Studio – or whether it’s easy to migrate an existing Eclipse project to Android Studio.

Thanks to the Android Studio importer and Eclipse’s export functionality, migrating an Eclipse project to Android Studio is relatively straightforward. If you’re eager to try Android Studio, there’s no reason why a half-finished Eclipse project should hold you back!

You have two options for migrating an Eclipse project to Android Studio. Firstly, you can export your project from Eclipse, use ADT to generate the necessary Gradle build file, and then import this project into Android Studio. Or, you can import your Eclipse project directly into Android Studio, without performing an export first.

Both approaches have certain advantages and disadvantages, which you need to take into account when deciding how to migrate your project.

Choose Your Migration Method

1. Import directly into Android Studio

This method is the quickest, and usually the easiest way to migrate a project. When you use Android Studio’s importer, it automatically makes some changes to your Eclipse project, which are designed to get your project up and running in its new IDE. These changes include replacing any JAR files and libraries with Gradle dependencies, and replacing source libraries and binary libraries, with Maven dependencies, so you no longer need to maintain these files manually.

The Android Studio importer also restructures your project based on the new Gradle directory layout. If you want to maintain Eclipse’s directory structure instead, you’ll need to export your project from Eclipse.

2. Export from Eclipse

This method is generally more time-consuming than importing an Eclipse project directly into Android Studio, but it does allow you to preserve Eclipse’s directory structure. This can be beneficial in various situations, for example when you want to work on the same codebase using both Android Studio and Eclipse. If your project contains lots of Eclipse-specific directory mappings, there’s also a chance that the Android Studio importer won’t resolve these paths properly during the restructuring process, so again you may want to use Eclipse’s project structure instead.

Perform Your Migration

1. Export from Eclipse

Before you start, check that Eclipse’s ADT plugin is up to date (you’ll need version 22.0 or higher). Open the ‘Help’ menu, and select ‘Check for Updates.’ If any updates are available, install them by following the onscreen instructions.

Once your ADT plugin is up to date, you’re ready to export your project:

1. Select File > Export.

2. In the window that appears, open the ‘Android’ folder and select ‘Generate Gradle build files.’ Click ‘Next.’

Generate Gradle
Generate Gradle

3. Select the project you want to export, and click ‘Next.’

4. Review your export options, and decide which modules Eclipse should export. Click ‘Finish.’

5. After a few moments, you’ll see an ‘export successful’ message, followed by the path where Eclipse has stored your exported project. Make a note of this location.

7. Open Android Studio. On the ‘Welcome’ screen, select ‘Import project.’

Import Project
Import Project

8. Navigate to your exported project, select it, and then click ‘Import.’

Android Studio will now import your project; after a few seconds, it’s ready for you to work on.

Note, version 0.9 of the Gradle plugin for Android introduced some incompatible changes, so you may need to tweak certain projects when you first import them into Android Studio. Essentially, if your project contains tests, for example instrumentation tests, you need to rename your ‘instrumentTest’ folders ‘androidTest,’ and update any test dependencies from ‘instrumentTestCompile,’ to ‘androidTestCompile.’ If this applies to your project, you can learn more at the Migrating From 0.8 to 0.9 guide.

2. Import Directly into Android Studio

The quickest way to get your Eclipse project into Android Studio is to skip performing an export, and instead import your Eclipse files directly into Android Studio.

This method requires you to know where Eclipse has stored your project. If you don’t already know your project’s full path, you can find out by opening the project in Eclipse. Then, in Eclipse’s Project Explorer, Control-click the project’s name, and select ‘Properties.’ The subsequent window contains the project’s full path.

Eclipse Properties
Eclipse Properties

Once you know where to find your Eclipse project, you can import it into Android Studio:

1. Launch Android Studio. On the ‘Welcome’ screen, opt to ‘Import Project.’

2. Navigate to where your Eclipse project is stored, and click ‘Import.’

3. Read the message explaining the import process, and then click ‘Next.’

4. At this point, Android Studio presents you with some options. Unless you have a specific reason not to, leave all these options selected.

Import Options
Import Options

5. Click ‘Finish,’ and Android Studio imports your project.

Once your import is complete, Android Studio displays an import summary, describing all the changes it’s made to your project. This summary contains details about which files were moved during the import process, and where you can find them in the new Android Gradle layout, plus information on any third party libraries or JAR files that Android Studio has replaced with Gradle dependencies. This import summary contains everything you need to know, to get up to speed with the Android Studio version of your original Eclipse project, so make sure you read it carefully.

Summary

In most instances, migrating a project to Android Studio should be a straightforward process, thanks to Android Studio’s direct importer. However, even if you plan to import all your Eclipse projects directly using the importer, at this early stage in Android Studio’s development, it makes sense to familiarize yourself with both options for migrating your Eclipse projects. If you’re ever struggling to import a particular Eclipse project directly (perhaps you’re encountering bugs with the importer, or your project is a difficult one for the importer to handle) exporting it from Eclipse first may be the answer.

For more information on Android Studio, check out the official documentation.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories