我尝试导入 acra http://code.google.com/p/acra/source/checkout到 eclipse 但 eclipse 假设它是标准的 java 项目所以 eclipse 显示导入错误
import android.app.Application;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.preference.PreferenceManager;
import android.util.Log;
我的意思是任何与 Android 相关的导入都会导致错误,在 IDE 中打开 acra 源代码的理想方法是什么?
Eclipse 中的Java 项目和Android 项目是有区别的。该项目应该是一个 Android 项目,以便正确解析 Android 导入。首先确保您拥有:
- Android SDK安装在您的计算机上。
- Android plugin安装在 Eclipse 中。
然后在 Eclipse 中转到菜单 File > Import
,选择 Android
,然后选择 Existing Android code into workspace
或者,您可以尝试使用肮脏的方式,将现有的 .project
文件更改为类似这样的内容
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ACRA</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>
我是一名优秀的程序员,十分优秀!