MenuActivity.java中的java.lang.NoClassDefFoundError

时间:2014-08-21 11:06:24

标签: android

我在运行时得到 java.lang.NoClassDefFoundError 。它指向Intent inHome = new Intent(MenuActivity.this,HomeActivity.class);行。我不知道如何解决这个问题。

堆栈跟踪:

 E/AndroidRuntime(931): FATAL EXCEPTION: main
 E/AndroidRuntime(931): Process: com.loco.android, PID: 931
 E/AndroidRuntime(931): java.lang.NoClassDefFoundError: com.sit.loco.activity.HomeActivity
 E/AndroidRuntime(931):     at com.sit.loco.activity.MenuActivity$3.onItemClick(MenuActivity.java:162)
 E/AndroidRuntime(931):     at android.widget.AdapterView.performItemClick(AdapterView.java:299)
 E/AndroidRuntime(931):     at android.widget.AbsListView.performItemClick(AbsListView.java:1113)
 E/AndroidRuntime(931):     at android.widget.AbsListView$PerformClick.run(AbsListView.java:2904)
 E/AndroidRuntime(931):     at android.widget.AbsListView$3.run(AbsListView.java:3638)
 E/AndroidRuntime(931):     at android.os.Handler.handleCallback(Handler.java:733)
 E/AndroidRuntime(931):     at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5017)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)                        
    at dalvik.system.NativeStart.main(Native Method)

MenuActivity.java:

    package com.sit.loco.activity;

    private Spinner spinner;
    private AppData appData;
    protected String language;
    private ArrayList<String> arraylist_language;
    private GridView gridView;
    private GridviewAdapter mAdapter;

    private ArrayList<Integer> listFlag;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu);

        appData = new AppData(getApplicationContext());
        prepareList();
        addListenerOnUi();

       private void addListenerOnUi() {


        // prepared arraylist and passed it to the Adapter class
        mAdapter = new GridviewAdapter(this, listFlag);

        gridView = (GridView) findViewById(R.id.gridView1);
        gridView.setAdapter(mAdapter);

        gridView.setOnItemClickListener(new OnItemClickListener() {

            @Override
        public void onItemClick(AdapterView<?> arg0, View arg1,
            int position, long arg3) {

        Intent inHome = new Intent(MenuActivity.this,HomeActivity.class);--->Error

                inHome.putExtra("position", position);
                startActivity(inHome);
            }
        });
    }
}   

HomeActivity.java:

package com.sit.loco.activity;

public class HomeActivity extends FragmentActivity
        implements
        VideoListFragment.DownLoadSelectedListner,

        CategoryFragment.OnCategorySelectedListener
   {

   @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        position = getIntent().getExtras().getInt("position");
    tab = actionabar.newTab().setText(getString(R.string.str_audio))
                .setTabListener(tabListener);
        if (position == 0) {
            actionabar.addTab(tab, 0, true);
        } else {
            actionabar.addTab(tab, 0, false);
        }


        tab = actionabar.newTab().setText(getString(R.string.str_settings))
                .setTabListener(tabListener);
        if (position == 1) {
            actionabar.addTab(tab, 1, true);
        } else {
            actionabar.addTab(tab, 1, false);
        }

        tab = actionabar.newTab()
                .setText(getString(R.string.str_prayer_request))
                .setTabListener(tabListener);
        if (position == 2) {
            actionabar.addTab(tab, 2, true);
        } else {
            actionabar.addTab(tab, 2, false);
        }

        tab = actionabar.newTab().setText(getString(R.string.str_gal))
                .setTabListener(tabListener);
        if (position == 3) {
            actionabar.addTab(tab, 3, true);
        } else {
            actionabar.addTab(tab, 3, false);
        }

        tab = actionabar.newTab().setText(getString(R.string.str_youtube))
                .setTabListener(tabListener);
        if (position == 4) {
            actionabar.addTab(tab, 4, true);
        } else {
            actionabar.addTab(tab, 4, false);
        }

        tab = actionabar.newTab().setText(getString(R.string.str_contact))
                .setTabListener(tabListener);
        if (position == 5) {
            actionabar.addTab(tab, 5, true);
        } else {
            actionabar.addTab(tab, 5, false);
        }

    }
    }

清单:

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

    <uses-sdk
        android:minSdkVersion="14"
        android:targetSdkVersion="19" />
   <application
        android:name="com.sit.loco.app.GemsApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.sit.loco.activity.SplashActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name="com.sit.loco.activity.MenuActivity" >
        </activity>

        <activity android:name="com.sit.loco.activity.HomeActivity" >
        </activity>
        <!-- Parent activity meta-data to support 4.0 and lower -->
        <activity android:name="com.sit.loco.activity.GalleryActivity" >
        </activity>


        <activity android:name="com.sit.loco.activity.AnnouncementActivity" >
        </activity>
        <activity android:name="com.sit.loco.activity.BlogActivity" >
        </activity>

         <activity android:name="com.sit.loco.activity.DownloadActivity" >
        </activity>

           <activity android:name="com.sit.loco.activity.VideoActivity" >
        </activity>

        <activity android:name="com.sit.loco.activity.PlayerActivity" >
        </activity>


        <!-- for admob, do not change this -->
        <activity android:name="com.google.ads.AdActivity"
              android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

    </application>

</manifest>

我不知道如何解决这个问题。任何人都可以帮助我。谢谢。

3 个答案:

答案 0 :(得分:0)

转到: -

项目&gt;属性&gt; Java构建路径&gt;订单&amp;导出并检查是否已选中项目正在使用的所有库。

答案 1 :(得分:0)

可能是因为未声明MenuActivity.java类:

公共类HomeActivity扩展活动{

@覆盖 protected void onCreate(Bundle savedInstanceState){

答案 2 :(得分:0)

在清单标记下,您的包是

       package="com.loco.android"

但是您的启动器活动已经

       com.sit.loco.

你可以请它赦免吗?