Home | History | Annotate | Download | only in installing
      1 page.title=Migrating to Android Studio
      2 
      3 @jd:body
      4 
      5 <div id="qv-wrapper">
      6 <div id="qv">
      7 
      8 
      9 <h2>In this document</h2>
     10 <ol>
     11   <li><a href="#overview">Migration Overview</a></li>
     12   <li><a href="#prerequisites">Migration Prerequisites</a></li>
     13   <li><a href="#migrate">Importing Projects to Android Studio</a></li>
     14   <li><a href="#post-migration">Validating imported projects</a></li>
     15 </ol>
     16 
     17 
     18 <h2>See also</h2>
     19 <ul>
     20   <li><a href="{@docRoot}tools/studio/eclipse-transition-guide.html">
     21     Transition Guide for Eclipse ADT</a></li>
     22   <li><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/FAQ+on+Migrating+to+IntelliJ+IDEA"
     23     class="external-link">IntelliJ FAQ on migrating to IntelliJ IDEA</a></li>
     24   <li><a href="http://confluence.jetbrains.com/display/IntelliJIDEA/IntelliJ+IDEA+for+Eclipse+Users"
     25     class="external-link">IntelliJ IDEA for Eclipse users</a></li>
     26   <li><a href="{@docRoot}tools/studio/index.html">Android Studio Overview</a></li>
     27 </ul>
     28 </div>
     29 </div>
     30 
     31 
     32 <p>Migrating from Eclipse ADT to Android Studio requires adapting to a new project structure,
     33 build system, and IDE functionality. To simplify the migration process, Android Studio provides an
     34 import tool so you can quickly transition your Eclipse ADT workspaces and Ant build scripts to
     35 Android Studio projects and <a href="http://www.gradle.org">Gradle</a>-based build files.</p>
     36 
     37 <p>This document provides an overview of the migration process and walks you
     38 through a sample import procedure. For more information about Android Studio features and the
     39 Gradle-based build system, see <a href="{@docRoot}tools/studio/index.html">Android Studio Overview</a>
     40 and <a href="{@docRoot}tools/building/configuring-gradle.html">Configuring Gradle Builds</a>.</p>
     41 
     42 
     43 
     44 <h2 id="overview">Migration Overview </h2>
     45 <p>Migrating from Eclipse to Android Studio requires that you change the structure of your
     46 development projects, move to a new build system, and use a new user interface. Here are some of
     47 the key changes you should be aware of as you prepare to migrate to Android Studio:</p>
     48 <ul>
     49   <li><strong>Project files</strong>
     50     <p>Android Studio uses a different project structure. Each Eclipse ADT
     51     project is called a module in Android Studio. Each instance of Android
     52     Studio contains a project with one or more app modules. For more information see,
     53     <a href="{@docRoot}tools/studio/eclipse-transition-guide.html#project-structure">Project
     54     Structure</a>.</p></li>
     55 
     56   <li><strong>Manifest settings</strong>
     57     <p>Several elements in the <code>AndroidManifest.xml</code> file are now properties in the
     58     <code>defaultConfig</code> and <code>productFlavors</code> blocks in the
     59     <code>build.gradle</code> file. These elements are still valid manifest entries and may
     60     appear in manifests from older projects, imported projects, dependencies, and libraries. For
     61     more information see,
     62     <a href="{@docRoot}tools/studio/eclipse-transition-guide.html#manifest-settings">Manifest
     63     Settings</a>.</p></li>
     64 
     65   <li><strong>Dependencies</strong>
     66     <p>Library dependencies are handled differently in Android Studio, using Gradle dependency
     67     declarations and Maven dependencies for well-known local source and binary libraries with
     68     Maven coordinates.  For more information see,
     69     <a href="{@docRoot}tools/studio/eclipse-transition-guide.html#dependencies">Dependencies</a></p>
     70     </li>
     71 
     72   <li><strong>Test code</strong>
     73     <p>With Eclipse ADT, test code is written in separate projects and integrated through the
     74     <code>&lt;instrumentation&gt;</code> element in your manifest file. Android Studio provides a
     75     <code>AndroidTest</code> folder within your project so you can easily add and maintain your test
     76     code within the same project view. JUnit tests can also be configured to run locally to reduce
     77     testing cycles.</p></li>
     78 
     79   <li><strong>Gradle-based build system</strong>
     80     <p>In place of XML-based Ant build files, Android Studio supports Gradle build files, which
     81     use the Gradle Domain Specific Language (DSL) for ease of extensibility and customization.
     82     The Android Studio build system also supports
     83     <a href="{@docRoot}tools/building/configuring-gradle.html#workBuildVariants"> build variants</a>,
     84     which are combinations of <code>productFlavor</code> and <code>buildTypes</code>, to customize
     85     your build outputs.</p></li>
     86 
     87   <li><strong>User interface</strong>
     88     <p>Android Studio provides an intuitive interface and menu options based on the
     89     <a class="external-link" href="https://www.jetbrains.com/idea/" target="_blank">IntelliJ IDEA</a>
     90     IDE. To become familiar with the IDE basics, such as navigation, code completion, and keyboard
     91     shortcuts, see
     92     <a class="external-link" href="https://www.jetbrains.com/idea/help/intellij-idea-quick-start-guide.html"
     93     target="_blank">IntelliJ IDEA Quick Start Guide</a>.</p></li>
     94 
     95   <li><strong>Developer tools versioning</strong>
     96     <p>Android Studio updates independently of the Gradle-based build system so different build
     97     settings can be applied across different versions of command line, Android Studio, and
     98     continuous integration builds. For more information, see
     99     <a href="{@docRoot}tools/building/configuring-gradle.html">Configuring Gradle Builds</a>.</p>
    100     </li>
    101 </ul>
    102 
    103 
    104 
    105 
    106 <h2 id="prerequisites">Migration Prerequisites</h2>
    107 <p>Before migrating your Eclipse ADT app to Android Studio, review the following steps to make
    108 sure your project is ready for conversion, and verify you have the tool configuration you need in
    109 Android Studio:</p>
    110 
    111 <ul>
    112  <li>In Eclipse ADT:
    113    <ul>
    114      <li>Make sure the Eclipse ADT root directory contains the <code>AndroidManifest.xml</code>
    115        file. Also, the root directory must contain either the <code>.project</code> and
    116        <code>.classpath</code> files from Eclipse or the <code>res/</code> and <code>src/</code>
    117        directories.</li>
    118      <li>Build your project to ensure your latest workspace and project updates are saved and
    119        included in the import.</li>
    120      <li>Comment out any references to Eclipse ADT workspace library files in the
    121        <code>project.properties</code> or <code>.classpath</code> files for import. You can
    122        add these references in the <code>build.gradle</code> file after the import. For more
    123        information, see
    124        <a href="{@docRoot}tools/building/configuring-gradle.html">Configuring Gradle Builds</a>.</li>
    125      <li>It may be useful to record your workspace directory, path variables, and any actual path
    126        maps that could be used to specify any unresolved relative paths, path variables, and
    127        linked resource references. Android Studio allows you to manually specify any unresolved
    128        paths during the import process.</li>
    129    </ul>
    130  </li>
    131  <li>In Android Studio:
    132    <ul>
    133     <li>Make a note of any third-party Eclipse ADT plugins in use and check for equivalent features
    134       in Android Studio or search for a compatible plugin in the
    135       <a href="https://plugins.jetbrains.com/?androidstudio" class="external-link">IntelliJ Android
    136       Studio Plugins</a> repository. Use the <strong>File &gt; Settings &gt; Plugins</strong> menu
    137       option to manage plugins in Android Studio. Android Studio does not migrate any third-party
    138       Eclipse ADT plugins.</li>
    139     <li>If you plan to run Android Studio behind a firewall, be sure to set the proxy settings for
    140       Android Studio and the SDK Manager. Android Studio requires an internet connection for
    141       Setup Wizard synchronization, 3rd-party library access, access to remote repositories,
    142       <a href="http://www.gradle.org" class="external-link">Gradle</a>
    143       initialization and synchronization, and Android Studio version updates. For more information,
    144       see <a href="{@docRoot}tools/studio/index.html#proxy">Proxy Settings</a>.</li>
    145     <li>Use the <strong>File &gt; Settings &gt; System Settings</strong> menu option to verify the
    146       current version and, if necessary, update Android Studio to the latest version from the
    147       stable channel. To install Android Studio, please visit the
    148       <a href="{@docRoot}sdk/index.html">Android Studio download page</a>.</li>
    149     </ul>
    150   </li>
    151  </ul>
    152 
    153 
    154 
    155 <h2 id="migrate">Importing Projects to Android Studio</h2>
    156 <p>Android Studio provides a function for importing Eclipse ADT projects, which creates a new
    157 Android Studio project and app modules based on your current
    158 Eclipse ADT workspace and projects. No changes are made to your Eclipse project files. The Eclipse
    159 ADT workspace becomes a new Android Studio project, and each Eclipse ADT project within the workspace
    160 becomes a new Android Studio module. Each instance of Android Studio contains a project with one or
    161 more app modules.</p>
    162 
    163 <p>After selecting an Eclipse ADT project to import, Android Studio creates the Android
    164 Studio project structure and app modules, generates the new Gradle-based build files and settings,
    165 and configures the required dependencies. The import options also allow you to enter your workspace
    166 directory and any actual path maps to handle any unresolved relative paths, path variables, and
    167 linked resource references.</p>
    168 
    169 <p>Depending on the structure of your Eclipse ADT development project, you should select specific
    170 files for importing:</p>
    171 <ul>
    172 <li>For workspaces with multiple projects, select the project folder for each Eclipse ADT
    173   project individually to import the projects into the same Android Studio project. Android
    174   Studio combines the Eclipse ADT projects into a single Android Studio project with different app
    175   modules for each imported project.</li>
    176 
    177 <li>For Eclipse ADT projects with separate test projects, select the test project folder for
    178   import. Android Studio imports the test project and then follows the dependency chain to import
    179   the source project and any project dependencies.</li>
    180 
    181  <li>If Eclipse ADT projects share dependencies within the same workspace, import each
    182    project individually into Android Studio. Android Studio maintains the shared dependencies
    183    across the newly created modules as part of the import process.</li>
    184 </ul>
    185 
    186 <p>To import a project to Android Studio:</p>
    187 
    188 <ol>
    189  <li>Start Android Studio and close any open Android Studio projects.</li>
    190  <li>From the Android Studio menu select <strong>File &gt; New &gt; Import Project</strong>.
    191   <p>Alternatively, from the <em>Welcome</em> screen, select <strong>Import project
    192   (Eclipse ADT, Gradle, etc.)</strong>.</p></li>
    193  <li>Select the Eclipse ADT project folder with the <code>AndroidManifest.xml</code> file
    194    and click <strong>Ok</strong>.
    195    <p> <img src="{@docRoot}images/tools/studio-select-project-forimport.png" alt="" /></p>
    196  </li>
    197  <li>Select the destination folder and click <strong>Next</strong>.
    198    <p> <img src="{@docRoot}images/tools/studio-import-destination-dir.png" alt="" /></p></li>
    199  <li>Select the import options and click <strong>Finish</strong>.
    200    <p>The import process prompts to migrate any library and project dependencies to Android Studio,
    201    and add the dependency declarations to the <code>build.gradle</code> file. The import process
    202    also replaces any well-known source libraries, binary libraries, and JAR files that have known
    203    Maven coordinates with Maven dependencies, so you no longer need to maintain these dependencies
    204    manually. The import options also allow you to enter your workspace directory and any actual
    205    path maps to handle any unresolved relative paths, path variables, and linked resource
    206    references.</p>
    207    <p> <img src="{@docRoot}images/tools/studio-import-options.png" alt="" /></p></li>
    208 
    209  <li>Android Studio imports the app and displays the project import summary. Review the summary
    210    for details about the project restructuring and the import process.
    211     <p> <img src="{@docRoot}images/tools/studio-import-summary.png"/></p>
    212  </li>
    213 </ol>
    214 
    215 <p>After importing the project from Eclipse ADT to the new Android Studio project and module
    216 structure, each app module folder in Android Studio contains the complete source set for that
    217 module, including the {@code src/main} and {@code src/androidTest} directories, resources, build
    218 file, and Android manifest. Before starting app development, you should resolve any issues shown in
    219 the project import summary to make sure the project re-structuring and import process completed
    220 properly.</p>
    221 
    222 
    223 
    224 <h3 id="post-migration">Validating imported projects</h3>
    225 <p>After completing the import process, use the Android Studio <strong>Build</strong> and
    226 <strong>Run</strong> menu options to build your project and verify the output. If your project
    227 is not building properly, check the following settings:</p>
    228 
    229 <ul>
    230 <ul>
    231   <li>Use the <strong>Android SDK</strong> button in Android Studio to launch the <a href=
    232   "{@docRoot}tools/help/sdk-manager.html">SDK Manager</a> and verify the installed versions of SDK
    233   tools, build tools, and platform match the settings for your Eclipse ADT project. Android Studio
    234   inherits the SDK Manager and JDK settings from your imported Eclipse project.
    235   </li>
    236   <li>Use the <strong>File &gt; Project Structure</strong> menu option to verify additional
    237     Android Studio settings:
    238    <ul>
    239      <li>Under <em>SDK Location</em> verify Android Studio has access to the correct SDK and
    240        JDK locations and versions. </li>
    241      <li>Under <em>Project</em> verify the Gradle version, Android Plugin version, and related
    242        repositories.</li>
    243      <li>Under <em>Modules</em> verify the app and module settings, such as signing configuration
    244        and library dependencies. </li>
    245    </ul>
    246  </li>
    247  <li>If your project depends on another project, make sure that dependency is defined properly in
    248   the <code>build.gradle</code> file in the app module folder.</li>
    249 </ul>
    250 
    251 
    252 <p>If there still are unexpected issues when building and running your project in Android
    253 Studio after you have checked these settings, consider modifying the Eclipse ADT project and
    254 re-starting the import process. Importing an Eclipse ADT project to Android Studio creates a new
    255 Android Studio project and does not impact the existing Eclipse ADT project. </p>
    256 
    257 
    258 
    259 <p>To get started using Android Studio, review the
    260 <a href="{@docRoot}tools/studio/index.html">Android Studio</a> features and
    261 <a href="http://www.gradle.org">Gradle</a>-based build system to become familiar with the new
    262 project and module structure, flexible build settings, and other advanced Android development
    263 capabilities. For a comparison of Eclipse ADT and Android Studio features and usage, see
    264 <a href="{@docRoot}tools/studio/eclipse-transition-guide.html">Transitioning to Android Studio from
    265 Eclipse</a>. For specific Android Studio how-to documentation, see the pages in the
    266 <a href="{@docRoot}tools/workflow/index.html">Workflow</a> section.
    267 </p>
    268