我正在尝试在一个项目中构建一个抽象类作为模板并在另一个项目中实现它们。但是,当尝试运行实现模板 Activity 的 Activity 时,会弹出 NoClassDefFoundError。我已将模板项目添加到另一个的 Java 构建路径中,在“订购和导出”中检查它,清理了项目,但没有任何帮助。我还尝试使用 1.6 编译器编译项目。所有结果都出现相同的错误。当尝试将模板项目添加为 JAR 时,Eclipse 说存在清单文件的副本,并且不允许这样做。
有谁知道我还能做些什么来解决这个问题?
这是我收到的错误日志:
04-05 00:29:09.941: E/AndroidRuntime(1348): FATAL EXCEPTION: main
04-05 00:29:09.941: E/AndroidRuntime(1348): java.lang.IllegalStateException: Could not execute method of the activity
04-05 00:29:09.941: E/AndroidRuntime(1348): at android.view.View$1.onClick(View.java:2144)
04-05 00:29:09.941: E/AndroidRuntime(1348): at android.view.View.performClick(View.java:2485)
04-05 00:29:09.941: E/AndroidRuntime(1348): at android.view.View$PerformClick.run(View.java:9080)
04-05 00:29:09.941: E/AndroidRuntime(1348): at android.os.Handler.handleCallback(Handler.java:587)
04-05 00:29:09.941: E/AndroidRuntime(1348): at android.os.Handler.dispatchMessage(Handler.java:92)
04-05 00:29:09.941: E/AndroidRuntime(1348): at android.os.Looper.loop(Looper.java:123)
04-05 00:29:09.941: E/AndroidRuntime(1348): at android.app.ActivityThread.main(ActivityThread.java:3683)
04-05 00:29:09.941: E/AndroidRuntime(1348): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 00:29:09.941: E/AndroidRuntime(1348): at java.lang.reflect.Method.invoke(Method.java:507)
04-05 00:29:09.941: E/AndroidRuntime(1348): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-05 00:29:09.941: E/AndroidRuntime(1348): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
04-05 00:29:09.941: E/AndroidRuntime(1348): at dalvik.system.NativeStart.main(Native Method)
04-05 00:29:09.941: E/AndroidRuntime(1348): Caused by: java.lang.reflect.InvocationTargetException
04-05 00:29:09.941: E/AndroidRuntime(1348): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 00:29:09.941: E/AndroidRuntime(1348): at java.lang.reflect.Method.invoke(Method.java:507)
04-05 00:29:09.941: E/AndroidRuntime(1348): at android.view.View$1.onClick(View.java:2139)
04-05 00:29:09.941: E/AndroidRuntime(1348): ... 11 more
04-05 00:29:09.941: E/AndroidRuntime(1348): Caused by: java.lang.NoClassDefFoundError: scf1984.games.testQuest.TestQuestActivity
04-05 00:29:09.941: E/AndroidRuntime(1348): at scf1984.games.testQuest.TestMainActivity.startTestQuest(TestMainActivity.java:18)
04-05 00:29:09.941: E/AndroidRuntime(1348): ... 14 more
和清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="scf1984.games.testQuest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="scf1984.games.testQuest.TestMainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="scf1984.games.testQuest.TestQuestActivity"
android:label="@string/app_name" >
</activity>
</application>
</manifest>
调用方法:
public void startTestQuest(View v) {
Intent i = new Intent(this,
scf1984.games.testQuest.TestQuestActivity.class);
startActivity(i);
}