Eclipse迁移到AndroidStudio的官方指导文档
2015-07-23 17:43
501 查看
Migrating to Android Studio
In this document
Migration OverviewMigration Prerequisites
Importing Projects to Android Studio
Validating imported projects
See also
Transition Guide for Eclipse ADTIntelliJ
FAQ on migrating to IntelliJ IDEA
IntelliJ
IDEA for Eclipse users
Android Studio Overview
Migrating from Eclipse ADT to Android Studio requires adapting to a new project structure, build system, and IDE functionality. To simplify the migration process, Android Studio provides an import
tool so you can quickly transition your Eclipse ADT workspaces and Ant build scripts to Android Studio projects and Gradle-based build files.
This document provides an overview of the migration process and walks you through a sample import procedure. For more information about Android Studio features and the Gradle-based build system, see Android
Studio Overview and Configuring Gradle Builds.
Migration Overview
Migrating from Eclipse to Android Studio requires that you change the structure of your development projects, move to a new build system, and use a new user interface. Here are some of the key changes you shouldbe aware of as you prepare to migrate to Android Studio:
Project files
Android Studio uses a different project structure. Each Eclipse ADT project is called a module in Android Studio. Each instance of Android Studio contains a project with one or more app modules. For more information
see, Project Structure.
Manifest settings
Several elements in the
AndroidManifest.xmlfile are now properties in the
defaultConfigand
productFlavorsblocks in the
build.gradlefile.
These elements are still valid manifest entries and may appear in manifests from older projects, imported projects, dependencies, and libraries. For more information see, Manifest
Settings.
Dependencies
Library dependencies are handled differently in Android Studio, using Gradle dependency declarations and Maven dependencies for well-known local source and binary libraries with Maven coordinates. For more information
see,Dependencies
Test code
With Eclipse ADT, test code is written in separate projects and integrated through the
<instrumentation>element in your manifest file. Android Studio provides a
AndroidTestfolder
within your project so you can easily add and maintain your test code within the same project view. JUnit tests can also be configured to run locally to reduce testing cycles.
Gradle-based build system
In place of XML-based Ant build files, Android Studio supports Gradle build files, which use the Gradle Domain Specific Language (DSL) for ease of extensibility and customization. The Android Studio build system
also supports build variants, which are combinations of
productFlavorand
buildTypes,
to customize your build outputs.
User interface
Android Studio provides an intuitive interface and menu options based on the IntelliJ
IDEA IDE. To become familiar with the IDE basics, such as navigation, code completion, and keyboard shortcuts, see IntelliJ
IDEA Quick Start Guide.
Developer tools versioning
Android Studio updates independently of the Gradle-based build system so different build settings can be applied across different versions of command line, Android Studio, and continuous integration builds. For more
information, see Configuring Gradle Builds.
Migration Prerequisites
Before migrating your Eclipse ADT app to Android Studio, review the following steps to make sure your project is ready for conversion, and verify you have the tool configuration you need in Android Studio:In Eclipse ADT:
Make sure the Eclipse ADT root directory contains the
AndroidManifest.xmlfile. Also, the root directory must contain either the
.projectand
.classpathfiles
from Eclipse or the
res/and
src/directories.
Build your project to ensure your latest workspace and project updates are saved and included in the import.
Comment out any references to Eclipse ADT workspace library files in the
project.propertiesor
.classpathfiles for import. You can add these references in the
build.gradlefile
after the import. For more information, seeConfiguring Gradle Builds.
It may be useful to record your workspace directory, path variables, and any actual path maps that could be used to specify any unresolved relative paths, path variables, and linked resource references. Android Studio allows
you to manually specify any unresolved paths during the import process.
In Android Studio:
Make a note of any third-party Eclipse ADT plugins in use and check for equivalent features in Android Studio or search for a compatible plugin in the IntelliJ
Android Studio Plugins repository. Use the File > Settings > Pluginsmenu option to manage plugins in Android Studio. Android Studio does not migrate any third-party Eclipse ADT plugins.
If you plan to run Android Studio behind a firewall, be sure to set the proxy settings for Android Studio and the SDK Manager. Android Studio requires an internet connection for Setup Wizard synchronization, 3rd-party library
access, access to remote repositories, Gradle initialization and synchronization, and Android Studio version updates.
For more information, see Proxy Settings.
Use the File > Settings > System Settings menu option to verify the current version and, if necessary, update Android Studio to the latest version from the stable channel. To install Android Studio, please visit
the Android Studio download page.
Importing Projects to Android Studio
Android Studio provides a function for importing Eclipse ADT projects, which creates a new Android Studio project and app modules based on your current Eclipse ADT workspace and projects. No changes are made toyour Eclipse project files. The Eclipse ADT workspace becomes a new Android Studio project, and each Eclipse ADT project within the workspace becomes a new Android Studio module. Each instance of Android Studio contains a project with one or more app modules.
After selecting an Eclipse ADT project to import, Android Studio creates the Android Studio project structure and app modules, generates the new Gradle-based build files and settings, and configures the required
dependencies. The import options also allow you to enter your workspace directory and any actual path maps to handle any unresolved relative paths, path variables, and linked resource references.
Depending on the structure of your Eclipse ADT development project, you should select specific files for importing:
For workspaces with multiple projects, select the project folder for each Eclipse ADT project individually to import the projects into the same Android Studio project. Android Studio combines the Eclipse ADT projects into a single
Android Studio project with different app modules for each imported project.
For Eclipse ADT projects with separate test projects, select the test project folder for import. Android Studio imports the test project and then follows the dependency chain to import the source project and any project dependencies.
If Eclipse ADT projects share dependencies within the same workspace, import each project individually into Android Studio. Android Studio maintains the shared dependencies across the newly created modules as part of the import
process.
To import a project to Android Studio:
Start Android Studio and close any open Android Studio projects.
From the Android Studio menu select File > New > Import Project.
Alternatively, from the Welcome screen, select Import project (Eclipse ADT, Gradle, etc.).
Select the Eclipse ADT project folder with the
AndroidManifest.xmlfile and click Ok.
Select the destination folder and click Next.
Select the import options and click Finish.
The import process prompts to migrate any library and project dependencies to Android Studio, and add the dependency declarations to the
build.gradlefile. The import process also replaces any
well-known source libraries, binary libraries, and JAR files that have known Maven coordinates with Maven dependencies, so you no longer need to maintain these dependencies manually. The import options also allow you to enter your workspace directory and any
actual path maps to handle any unresolved relative paths, path variables, and linked resource references.
Android Studio imports the app and displays the project import summary. Review the summary for details about the project restructuring and the import process.
After importing the project from Eclipse ADT to the new Android Studio project and module structure, each app module folder in Android Studio contains the complete source set for that module, including the
src/mainand
src/androidTestdirectories,
resources, build file, and Android manifest. Before starting app development, you should resolve any issues shown in the project import summary to make sure the project re-structuring and import process completed properly.
Validating imported projects
After completing the import process, use the Android Studio Build and Run menu options to build your project and verify the output. If your project is not building properly, checkthe following settings:
原文链接:http://developer.android.com/sdk/installing/migrate.html
相关文章推荐
- 使用C++实现JNI接口需要注意的事项
- Android IPC进程间通讯机制
- Android Manifest 用法
- [转载]Activity中ConfigChanges属性的用法
- Android之获取手机上的图片和视频缩略图thumbnails
- Android之使用Http协议实现文件上传功能
- Android学习笔记(二九):嵌入浏览器
- android string.xml文件中的整型和string型代替
- i-jetty环境搭配与编译
- android之定时器AlarmManager
- android wifi 无线调试
- Android Native 绘图方法
- Android java 与 javascript互访(相互调用)的方法例子
- android 代码实现控件之间的间距
- android FragmentPagerAdapter的“标准”配置
- Android"解决"onTouch和onClick的冲突问题
- android:installLocation简析
- android searchView的关闭事件
- SourceProvider.getJniDirectories