将Eclipse工程迁移到Android Stutio

具体步骤见:

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


你可能感兴趣的:(eclipse,android,gradle)