最近迷上了IntelliJ IDEA,就Android开发而言,确实要比Eclipse好用,尤为是对于Layout的布局,很是方便,可是公司大部分同事使用的仍是Eclipse,这就存在一个问题——我建立的工程,怎么能让其余同事导入并开发。虽然IDEA提供了“Export to Eclipse”,可是在实际过程当中仍是存在问题的——Eclipse在import时,不能将这个Android工程正确识别,老是做为Java工程导入,通过反复试验,终于找到了问题——“.project”这个文件在搞鬼,具体解决方法以下:
java
- <?xml version="1.0" encoding="UTF-8"?>
- <projectDescription>
- <name>IDEATest</name>
- <comment/>
- <projects/>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments/>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
- </projectDescription>
上面是使用IDEA建立的Android module在执行Export to Eclipse后的.project文件中的所有内容。这些内容是Eclipse工程的最基本的内容,要想让Eclipse能将其正确识别为Android工程,要进行以下修改
android
- <?xml version="1.0" encoding="UTF-8"?>
- <projectDescription>
- <name>IDEATest</name>
- <comment/>
- <projects/>
- <buildSpec>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
- <arguments/>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
- <arguments/>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>
- <arguments/>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments/>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
- </projectDescription>
其中第7行至第18行,以及第25行,都是要本身添加的内容,添加完毕之后保存,再次将工程导入到Eclipse,这下就能正确识别为Android工程了。若是导入后出现了error,不要慌,能够使用Android Tools->Fix Project Properties来解决错误。eclipse