IntelliJ IDEA Export to Eclipse Android工程不能正常被Eclipse识别的解决方法

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

  
  
  
  
  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工程,要进行以下修改
 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来解决错误。eclipse

相关文章
相关标签/搜索