簡體   English   中英

Android中的Java.lang.NoClassDefFoundError

[英]Java.lang.NoClassDefFoundError in android

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

    }

在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)

問題:調用Intent時。 為什么這個? 我不知道?? 在Google上搜索了很多時間,但是找不到任何合適的解決方案來解決問題。

代碼可能看起來像這樣,

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

請確保如果活動類位於其他軟件包中,則軟件包名稱必須包含在清單文件中,如下所示:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM