Thomas Besnehard
Thomas Besnehard

Reputation: 2095

java.lang.NoClassDefFoundError, on one of my own class

On my home activity, I am using in a thread, and Intent to one of my own class :

public class AppHome extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
        /* some initialisations */
        Thread initThread = new Thread() {

            @Override
    public void run() {
        try {
            super.run();
            /* some treatment */
            lanchNextActivity(nextActivity);
        }
    };
    initThread.start();
     }

private void lanchNextActivity(String activity){

    Intent intent = new Intent(context, ZonesActivity.class);
    startActivity(intent);
}
}

It crash on my ZonesActivity.class whith the following message

threadid=12: thread exiting with uncaught exception (group=0x40a13300)
FATAL EXCEPTION: Thread-120
java.lang.NoClassDefFoundError: com.dombox.app.activity.ZonesActivity
    at com.dombox.app.activity.DomboxHome.lanchNextActivity(DomboxHome.java:309)
    at com.dombox.app.activity.DomboxHome.access$1(DomboxHome.java:291)
    at com.dombox.app.activity.DomboxHome$1.run(DomboxHome.java:276)

AppHome.java:309 is the creation of the Intent.

And my class ZonesActivity is maid by me :

package com.dombox.app.activity;

public class ZonesActivity extends FragmentActivity { /* ... */ }

I'm thinking the is something wrong with my Class Path, but it seem normal to me :

here is my classpath

And my manifest :

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.myapp.app"
    android:versionCode="13"
    android:versionName="2.1.1" xmlns:android="http://schemas.android.com/apk/res/android">

    <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8"/>

    <supports-screens android:largeScreens="true"
        android:normalScreens="true" android:smallScreens="true"
        android:anyDensity="true" />

    <permission android:name="com.myapp.app.permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        <uses-library android:name="android.test.runner" />

        <activity android:name=".activity.ZonesActivity"                    
            android:label="@string/app_name"></activity>

        <instrumentation
            android:name="android.test.InstrumentationTestRunner"
            android:label="Tests for Android MyApp"
            android:targetPackage="com.application.androidmyapp" >
        </instrumentation>
    </application>
</manifest>

Sorry the manifest is quite big !

does anyone has a idea ?

Upvotes: 3

Views: 900

Answers (2)

Sam
Sam

Reputation: 42357

In my case, the problem was my class was inheriting from a class that was only available in API 24+.

I was inheriting from SensorEventCallback, and I fixed it by implementing SensorEventListener instead.

Upvotes: 0

Yichuan Wang
Yichuan Wang

Reputation: 753

If you used any API that's not available on the current platform. (E.g. calling ICS APIs on older phones). The system will throw this rather misleading exception.

Upvotes: 3

Related Questions