一:问题描述:
Eclipse中导入Eclipse格式的Android工程,未能正确识别为Android工程,识别成了Java工程。
二:原因分析:
Eclispe工程中的 .project 文件是识别工程的关键文件。
Java工程的 .project 文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>HelloWorld</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Android工程的 .project 文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Assetinventory</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>
由于我的工程是从SVN上面拉取下来的,SVN上面的工程没有上传 .project 文件,故而编辑器自动生成了Java的 .project 文件。
三:解决方案:
将出错的 .project 文件替换为正确的 .project文件即可。