1. 程式人生 > >Intellij IDEA 和 Eclipse 專案相互轉換

Intellij IDEA 和 Eclipse 專案相互轉換

        公司的預設android開發工具是eclipse,不太喜歡使用eclipse,所以早早的就換成Intellij  IDEA了,今天在使用IDEA轉換成eclipse專案時出現問題了。

IDEA預設是可以開啟eclipse專案的,我需要把IDEA專案轉換成eclipse專案後,提交到程式碼伺服器。使用“File”  -> “Export to Eclipse” 可以轉換成eclipse專案,

會在專案下生成 ".classpath'和‘.project’檔案。我把IDEA對應的檔案(.idea目錄和iml檔案等)刪除中,用IDEA重新開啟這個專案,發現編譯不通過。

        查看了一下生成的'.classpath'和‘.project’檔案,發現這兩個檔案的配置資訊不正確,改成下面的後就正常了。

        .project 檔案對應的內容:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
	<name>example</name>
	<comment></comment>
	<projects>
	</projects>
	<buildSpec>
		<buildCommand>
			<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>org.eclipse.jdt.core.javabuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
		<buildCommand>
			<name>com.android.ide.eclipse.adt.ApkBuilder</name>
			<arguments>
			</arguments>
		</buildCommand>
	</buildSpec>
	<natures>
		<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
		<nature>org.eclipse.jdt.core.javanature</nature>
	</natures>
</projectDescription>
   需要將上面的"<name>quick</name>" 改成對應的專案名。

   .classpath對應的內容如下:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src"/>
	<classpathentry kind="src" path="gen"/>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
	<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
	<classpathentry kind="output" path="bin/classes"/>
</classpath>

改好以後,用IDEA開啟這個eclipse專案,編譯通過。