最近迷上了IntelliJ IDEA,就Android开发而言,确实要比Eclipse好用,尤其是对于Layout的布局,非常方便,但是公司大部分同事使用的还是Eclipse,这就存在一个问题——我创建的工程,怎么能让其他同事导入并开发。虽然IDEA提供了“Export to Eclipse”,但是在实际过程中还是存在问题的——Eclipse在import时,不能将这个Android工程正确识别,总是作为Java工程导入,经过反复试验,终于找到了问题——“.project”这个文件在搞鬼,具体解决方法如下:
 

 
  
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <projectDescription> 
  3.     <name>IDEATest</name> 
  4.     <comment/> 
  5.     <projects/> 
  6.     <buildSpec> 
  7.         <buildCommand> 
  8.             <name>org.eclipse.jdt.core.javabuilder</name> 
  9.             <arguments/> 
  10.         </buildCommand> 
  11.     </buildSpec> 
  12.     <natures> 
  13.         <nature>org.eclipse.jdt.core.javanature</nature> 
  14.     </natures> 
  15. </projectDescription> 

上面是使用IDEA创建的Android module在执行Export to Eclipse后的.project文件中的全部内容。这些内容是Eclipse工程的最基本的内容,要想让Eclipse能将其正确识别为Android工程,要进行如下修改
 

 
  
  1. <?xml version="1.0" encoding="UTF-8"?> 
  2. <projectDescription> 
  3.     <name>IDEATest</name> 
  4.     <comment/> 
  5.     <projects/> 
  6.     <buildSpec> 
  7.         <buildCommand> 
  8.             <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name> 
  9.             <arguments/> 
  10.         </buildCommand> 
  11.         <buildCommand> 
  12.             <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name> 
  13.             <arguments/> 
  14.         </buildCommand> 
  15.         <buildCommand> 
  16.             <name>com.android.ide.eclipse.adt.ApkBuilder</name> 
  17.             <arguments/> 
  18.         </buildCommand>
  19. <buildCommand> 
  20.             <name>org.eclipse.jdt.core.javabuilder</name> 
  21.             <arguments/>
  22.         </buildCommand>
  23.     </buildSpec> 
  24.     <natures> 
  25.         <nature>com.android.ide.eclipse.adt.AndroidNature</nature> 
  26.         <nature>org.eclipse.jdt.core.javanature</nature> 
  27.     </natures> 
  28. </projectDescription> 

其中第7行至第18行,以及第25行,都是要自己添加的内容,添加完毕以后保存,再次将工程导入到Eclipse,这下就能正确识别为Android工程了。如果导入后出现了error,不要慌,可以使用Android Tools->Fix Project Properties来解决错误。