简体   繁体   English

Android中的Java.lang.NoClassDefFoundError

[英]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. 自1天以来,我一直无法解决此问题,在AsyncTask及其执行后的意图调用期间,我遇到了它。

@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 在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 . 问题:调用Intent时。 why this? 为什么这个? i don;t know?? 我不知道?? Search on google lots of time but could not find any proper solution to get out. 在Google上搜索了很多时间,但是找不到任何合适的解决方案来解决问题。

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> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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