具体步骤见:

http://developer.android.com/sdk/installing/migrate.html


这里只记录一些注意事项和迁移过程中遇到的问题的解决方案。

1)在导入前注释掉project.properties和.classpath文件中的对ADT库文件的引用。
2)通过File->New->Import Project或 在欢迎页面,选择Import project(Eclipse ADT,Gradle,etc)来导入工程。

导入的工程会生出一个import-summary.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:


* ic_launcher-web.png
* proguard-project.txt


Replaced Jars with Dependencies:
--------------------------------
The importer recognized the following .jar files as third party
libraries and replaced them with Gradle dependencies instead. This has
the advantage that more explicit version information is known, and the
libraries can be updated automatically. However, it is possible that
the .jar file in your project was of an older version than the
dependency we picked, which could render the project not compileable.
You can disable the jar replacement in the import wizard and try again:


android-support-v4.jar => com.android.support:support-v4:23.1.1


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
* assets\ => app\src\main\assets
* 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.)


3)导入后遇到的问题:

1, Error:Cannot locate factory for objects of type DefaultGradleConnector, as ConnectorServiceRegistry has been closed.

该问题参见如下连接,是Gradle的同步问题,目前的解决方案是重启。

http://stackoverflow.com/questions/27724883/gradle-project-refresh-failed-android-studio

https://code.google.com/p/android/issues/detail?id=80591

2,Error:(16, 0) GradleDSL method not found: 'android()'

Possible causes: The project 'ApiExDemos'may be using a version of Gradle that does not contain the method.Open Gradlewrapper file

The build file may be missing a Gradleplugin.

Apply Gradle plugin

解决方法,删除根目录build.gradle中的android配置。

android {
compileSdkVersion 21
buildToolsVersion '21.1.2'
}

参考:

https://medium.com/@marcuspereira/solving-the-gradle-dsl-method-not-found-android-in-android-studio-6e5ab499bd3


更多相关文章

  1. 如何判断 两个不同包名的 Android(安卓)应用的 Apk 签名是否一致
  2. 解决“密钥库文件不存在: debug.keystore”
  3. Android模块化编译
  4. 在Android中创建启动界面
  5. Android通过startService实现文件批量下载
  6. Android项目创建和项目目录图解
  7. Android(安卓)自定义属性时TypedArray的使用
  8. Android插件DSL参考
  9. Android(安卓)Studio3.0 Kotlin工程问题集

随机推荐

  1. 检测android机器是否有GPS模块
  2. Android(安卓)图片缩放,图片圆角处理
  3. android 常用代码
  4. android Rect的使用
  5. 【Android代码片段之三】TabActivity实现
  6. Android(安卓)百度地图-实现POI的搜索(搜
  7. android O 手机关机流程与时间
  8. Layout inflation is the term used with
  9. Android之键盘点击事件
  10. android Manifest merger failed : Attri