Android Project migration from Eclipse to Android Studio
Android Studio is the official IDE for Android development, and with a single download includes everything you need to begin developing Android apps.
This example describes the differences between Eclipse ADT and Android Studio, including project structure, build system, and application packaging, and will help you migrate your Android Eclipse project to Android Studio as your new development environment.
For our example will use the following tools in a Windows 64-bit or an OS X platform:
- JDK 1.7
- Android Studio 1.3.2
- Eclipse 4.2 Juno
- Android SDK
You may skip the theoretical part and jump directly to the beginning of the example below.
Let’s start with a slice of Android Studio theory…
1. Why to use Android Studio over Eclipse ADT?
Android Studio offers:
- Flexible Gradle-based build system
- Build variants and multiple apk file generation
- Code templates to help you build common app features
- Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine
- Rich layout editor with support for drag and drop theme editing
- lint tools to catch performance, usability, version compatibility, and other problem
- Built-in support for Google Cloud Platform, making it easy to integrate Google Cloud Messaging and App Engine
- Official Google Support and usual updates that need no migration
2. Android Studio new project structure
Eclipse provides workspaces as a common area for grouping related projects, configurations, and settings. In Android Studio, each instance of Android Studio contains a top-level project with one or more app modules. Each app module folder contains the equivalent to an Eclipse project, the complete source sets for that module, including src/main and src/androidTest directories, resources, build file, and the Android manifest. In general, to update and build your app you modify the files under each module’s src/main directory for source code updates, the gradle.build file for build specification, and the files under src/androidTest directory for test case creation. Also due to the structural differences between Android Studio projects vs Eclipse ADT projects, they cannot co-exist. Here is a table of the main differences:
| Eclipse ADT | Android Studio |
|---|---|
| Workspace | Project |
| Project | Module |
| Project-specific JRE | Module JDK |
| Classpath variable | Path variable |
| Project dependency | Module dependency |
| Library Module | Library |
AndroidManifest.xml | app/src/main/AndroidManifest.xml |
assets/ | app/src/main/assets |
res/ | app/src/main/res/ |
src/ | app/src/main/java/ |
tests/src/ | app/src/androidTest/java/ |
3. Gradle and build.gradle
Gradle is a build and automation tool, that can automate our building, testing, deploying tasks and many more. Gradle is the next generation build system for Java technologies that includes some advantages from older tools like Ant or Maven systems. Android Studio uses the power of Gradle, in order to provide all the above advantages, such as build variants and multiple apk file generation.
Android Studio projects contain a top-level build file and a build file for each module. The build files are called build.gradle, and they are plain text files that use Groovy syntax to configure the build with the elements provided by the Android plugin for Gradle. In most cases, you only need to edit the build files at the module level.
It looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile project(":lib")
compile 'com.android.support:appcompat-v7:19.0.1'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
4. Simple Eclipse ADT project migration to Android Studio
Here, we have an example of this Eclipse ADT project migration to Android Studio. In this example, we are going to migrate the eclipse project that we created in this example: Download NOW!






