简体   繁体   中英

Java.lang.NoClassDefFoundError in android

I am unable solve this problem since 1 days, i faced when in AsyncTask and its on postexecute, during intent call it occurs.

@Override
        protected void onPostExecute(Void result) {
            super.onPostExecute(result);
            // Dismiss the progress dialog
            try {
                Intent isplash= new Intent(Splash.this,MainPage.class);
                startActivity(isplash);
                finish();
            } catch (Exception e) {
                e.printStackTrace();
            } 

    }

in menefest.xml

<activity android:name=".MainPage" 
            android:screenOrientation="landscape"></activity>

and faced errors:

Unable to resolve superclass of Lco/test/MainPage; (130)
Link of class 'Lco/test/MainPage;' failed
Could not find class 'co.test.MainPage', referenced from method co.test.Splash$GetData.onPostExecute
VFY: unable to resolve const-class 320 (Lco/test/MainPage;) in Lco/test/Splash$GetData;

and

FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: co.test.MainPage
at co.test.Splash$GetData.onPostExecute(Splash.java:1732)
at co.test.Splash$GetData.onPostExecute(Splash.java:1)
at android.os.AsyncTask.finish(AsyncTask.java:602)
at android.os.AsyncTask.access$600(AsyncTask.java:156)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:615)

Problem: when call Intent . why this? i don;t know?? Search on google lots of time but could not find any proper solution to get out.

the code might look something like this,

public class MyAsyncTask extends AsyncTask {

    Context context;
    private MyAsyncTask(Context context) {
        this.context = context.getApplicationContext();
    }

    @Override
    protected Object doInBackground(Object... params) {
        ...
    }

    @Override
    protected void onPostExecute(List<VideoDataDescription> result) {
        super.onPostExecute(result);
        MainActivity.progressDialog.dismiss();

        context.startActivity(new Intent(context, ResultsQueryActivity.class));
    }
}

you'd call it like this:

 new MyAsyncTask(context).execute();

Please make sure that if activity class lies in different package, package name must be included in manifest file like this:

 <activity android:name="co.test.MainPage" android:screenOrientation="landscape"></activity> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM