Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Migrating Your Android App from Eclipse to Android Studio

DZone's Guide to

Migrating Your Android App from Eclipse to Android Studio

· Mobile Zone
Free Resource

Launching an app doesn’t need to be daunting. Whether you’re just getting started or need a refresher on mobile app testing best practices, this guide is your resource! Brought to you in partnership with Perfecto

Curator's Note: The content of this article was written by Jason Snell over at the New Relic blog. 

One of the more exciting announcements from Google IO this year was the Android Team’s decision to release Android Studio. Android Studio isJetBrains’ IntelliJ IDEA with a brand new, extremely rich, Android-focused plugin. (It’s similar to Eclipse with the ADT package.) If you’re feeling adventurous, give it a spin by migrating one of your Eclipse apps.

Getting Started
First, you’ll need to update your SDK installation to the latest version. (Versions 22.0.0 and up will migrate your app to Android Studio.) After a few SDK Manager updates and restarts, you should see something like this:

Android Studio packages

Now you’re ready to export your application from Eclipse. Google chose Gradle as the new Android build system, so we’ll generate the necessary build files first. From the Eclipse menu, choose ‘File’ and then click ‘Export’. Under the Android folder, you’ll find ‘Generate Gradle build files’:

Android Studio Generate Gradle build files

Choose the project you want to migrate and click ‘Finish’.  Next, exit Eclipse and fire up Android Studio. You’ll want to import an existing project. You can do it from the File menu or the wizard if you don’t have a project opened. Navigate to the directory containing your app and double click the build.gradle file:

Android Studio: Select File or Directory to Import

Now you’re almost there! Check ‘Use auto-import’ and select the Gradle wrapper. Or you can choose a Gradle distribution location if you have Gradle 1.6 installed. (This will skip the step of adding a few files to your project directory.) When you click ‘Finish’, Android Studio will perform a few housekeeping tasks and open your shiny new Gradle project. Hurray!

Android Studio: Import Project

Bonus Round
Now that you’re working happily in Android Studio, isn’t it time to add a little New Relic action to the mix? Don’t have a New Relic account? (Sign up for one today and get a free 30-day trial!)

First, merge the following into your build.gradle file:

buildscript {
  dependencies {
    classpath 'com.newrelic.agent.android:agent-gradle-plugin:2.397.0'
  }
}
 
repositories {
  mavenCentral()
}
 
apply plugin: 'android'
apply plugin: 'newrelic'
 
dependencies {
  compile 'com.newrelic.agent.android:android-agent:2.397'
}

Then add an import to your default Activity class:

import com.newrelic.agent.android.NewRelic;

And in the onCreate() method, add this call to initialize New Relic:

NewRelic.withApplicationToken("<your mobile app token>").start(this.getApplication());

That’s it! We’d love to hear about your migration stories. Let us know your experiences in the comments below.








Keep up with the latest DevTest Jargon with the latest Mobile DevTest Dictionary. Brought to you in partnership with Perfecto.

Topics:

Published at DZone with permission of Leigh Shevchik, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}