2.2 将已有Eclipse ADT项目导入Android Studio

打开Android Studio,在欢迎界面可以看到有一条选项Import project(Eclipse ADT,Gradle,etc.),如G 1.

2.2 将已有Eclipse ADT项目导入Android Studio_第1张图片
G 1

选中后就可以从打开的窗口选择想要导入的项目.可以看到 res, srcAndroidManifest.xml都在项目的根目录,很显然,这是一个Eclipse工程:

2.2 将已有Eclipse ADT项目导入Android Studio_第2张图片
G 2

然后再指定要导入到的路径,会提示将lib文件夹下的jar包添加到Gradle文件的dependencies里:

2.2 将已有Eclipse ADT项目导入Android Studio_第3张图片
G 3

然后Android Studio会开始重组并构建工程,重构结束后默认打开一个importsummary.txt文件,告知我们重构后主要有哪些改变:

ECLIPSE ANDROID PROJECT IMPORT SUMMARY
======================================

Ignored Files:
--------------
The following files were *not* copied into the new Gradle project; you
should evaluate whether these are still needed in your project and if
so manually move them:

* .gitignore
* LICENSE.txt
* README.md
* proguard.cfg

Moved Files:
------------
Android Gradle projects use a different directory structure than ADT
Eclipse projects. Here's how the projects were restructured:

* AndroidManifest.xml => app\src\main\AndroidManifest.xml
* libs\commons-httpclient-3.1.jar => app\libs\commons-httpclient-3.1.jar
* res\ => app\src\main\res\
* src\ => app\src\main\java\

Next Steps:
-----------
You can now build the project. The Gradle project needs network
connectivity to download dependencies.

Bugs:
-----
If for some reason your project does not build, and you determine that
it is due to a bug or limitation of the Eclipse to Gradle importer,
please file a bug at http://b.android.com with category
Component-Tools.

(This import summary is for your information only, and can be deleted
after import once you are satisfied with the results.)

在生成的settings.gradle文件里会显示

include ':app'

说明app工程是项目里唯一的模块.
需要注意的是,在整个重构过程中,清单文件并没有改变:




    

    
      
 
    
    

既然我们已经将工程重构为了Android Studio工程,所以最好还是将清单文件内容改为Android Studio默认的格式,将uses-sdk内容写到build.gradle文件里.

你可能感兴趣的:(2.2 将已有Eclipse ADT项目导入Android Studio)