scf
scf

Reputation: 406

Android and Eclipse - java.lang.NoClassDefFoundError with project dependency

I'm trying to build a abstract classes in one project as a template and to implement them in another. However when trying to run an Activity that implements the template Activity, the NoClassDefFoundError pops up. I've added the template project to the Java Build Path of the other one, checked it in "Order and Export", cleaned the project, but nothing helps. I also tried to compile the project with the 1.6 compiler. All resulted with the same error. When trying to add the template project as a JAR Eclipse says there's a duplicate of Manifest files and won't allow it.

Does anyone has any idea what else I can do to fix this problem?

Here's the error log I receive:

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

And the manifest:

<?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>

The invoking method:

    public void startTestQuest(View v) {
    Intent i = new Intent(this,
            scf1984.games.testQuest.TestQuestActivity.class);
    startActivity(i);
}

Upvotes: 3

Views: 3729

Answers (3)

Code-Apprentice
Code-Apprentice

Reputation: 83527

You need to mark your "template project" as an Android library project. Go to Project->Properties->Android and checked the "is library".

Upvotes: 2

이수홍
이수홍

Reputation: 43

Intent intent = (Intent)new Intent();

intent.setClassName(package name, package name + class);

startActivity(intent);

try this

Upvotes: 0

f2prateek
f2prateek

Reputation: 2084

Most likely you're missing the activity declaration in the Android manifest. You should pastebin the full error and your AndroidManifest.xml

Upvotes: 0

Related Questions