2015-03-25 61 views
0

我无法解决这个问题,因为1天后,我遇到了当在AsyncTask及其上的postexecute,在意图调用它发生。Android中的Java.lang.NoClassDefFoundError

@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(); 
      } 

    } 

在menefest.xml

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

,面对错误:

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; 

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) 

问题:当调用的意图。为什么这个?我不知道?? 在谷歌上搜索很多时间,但找不到任何合适的解决方案。

+1

你是否在manifest中定义了mainpage.java? – 2015-03-25 08:59:17

+0

@Bixms显示'MainPage'类和清单 – nikis 2015-03-25 09:01:45

+0

不需要将Intent块放在postExecute()中,只是做简单的 – 2015-03-25 09:02:27

回答

2

的代码可能是这个样子,

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)); 
    } 
} 

你这样称呼它:

new MyAsyncTask(context).execute(); 
+0

仍然有同样的问题。我尝试这种方式,但没有工作。 – Bixms 2015-03-25 09:40:39

+0

在我的情况下,它的工作完美请张贴您的mainpage.java和Splash.java – 2015-03-25 09:46:07

+0

嘿请检查这个链接,我认为这将有助于你http://stackoverflow.com/questions/6168841/unable-to-resolve-superclass -error-when-referencing-jar-library – 2015-03-25 09:55:05

0

请确保,如果活动课就在于不同的包,包的名称必须是列入清单文件是这样的:

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

+0

也试过这个,但仍然是同样的错误。 – Bixms 2015-03-25 09:24:14

相关问题