启动应用程序时发生致命错误(E/AndroidRuntime(4881):致命异常:主要)

Fatal Error While Starting Application (E/AndroidRuntime(4881): FATAL EXCEPTION: main)

我是 ubuntu 的新手,我使用 ubuntu 14:04。 android应用是能够在Windows上运行之前,不知道为什么ubuntu应用,这些应用不能运行。问候

这是我的mainactivity.java

package com.iv.daging;

import com.special.ResideMenu.ResideMenu;
import com.special.ResideMenu.ResideMenuItem;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Toast;
import android.os.Bundle;

public class MainActivity extends FragmentActivity implements View.OnClickListener{

    private ResideMenu resideMenu;
    private MainActivity mContext;
    private ResideMenuItem itemHome;
    private ResideMenuItem itemIdentification;
    private ResideMenuItem itemRecent;
    private ResideMenuItem itemAbout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mContext = this;
        setUpMenu();
        if( savedInstanceState == null )
            changeFragment(new HomeFragment());
    }

    @Override
    public void onClick(View view) {
        if (view == itemHome){
            changeFragment(new HomeFragment());
        }else if (view == itemIdentification){
            changeFragment(new IdetificationFragment());
        }else if (view == itemRecent){
            changeFragment(new RecentFragment());
        }else if (view == itemAbout){
            changeFragment(new AboutFragment());
        }

        resideMenu.closeMenu();
    }

    private void changeFragment(Fragment targetFragment){
        resideMenu.clearIgnoredViewList();
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.main_fragment, targetFragment, "fragment")
                .setTransitionStyle(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
                .commit();
    }

    // What good method is to access resideMenu?
    public ResideMenu getResideMenu(){
        return resideMenu;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent ev) {
        return resideMenu.dispatchTouchEvent(ev);
    }

    private void setUpMenu() {
        // attach to current activity;
        resideMenu = new ResideMenu(this);
        resideMenu.setBackground(R.drawable.menu_background);
        resideMenu.attachToActivity(this);
        resideMenu.setMenuListener(menuListener);
        //valid scale factor is between 0.0f and 1.0f. leftmenu'width is 150dip. 
        resideMenu.setScaleValue(0.6f);

        // create menu items;
        itemHome     = new ResideMenuItem(this, R.drawable.icon_home,"Home");
        itemIdentification  = new ResideMenuItem(this, R.drawable.icon_home,"Identification");
        itemRecent = new ResideMenuItem(this, R.drawable.icon_home,"Recent");
        itemAbout = new ResideMenuItem(this, R.drawable.icon_home,"About");

        itemHome.setOnClickListener(this);
        itemIdentification.setOnClickListener(this);
        itemRecent.setOnClickListener(this);
        itemAbout.setOnClickListener(this);

        resideMenu.addMenuItem(itemHome, ResideMenu.DIRECTION_RIGHT);
        resideMenu.addMenuItem(itemIdentification, ResideMenu.DIRECTION_RIGHT);
        resideMenu.addMenuItem(itemRecent, ResideMenu.DIRECTION_RIGHT);
        resideMenu.addMenuItem(itemAbout, ResideMenu.DIRECTION_RIGHT);
    }

    private ResideMenu.OnMenuListener menuListener = new ResideMenu.OnMenuListener() {
        @Override
        public void openMenu() {
            Toast.makeText(mContext, "Menu is opened!", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void closeMenu() {
            Toast.makeText(mContext, "Menu is closed!", Toast.LENGTH_SHORT).show();
        }
    };
}

这是我的长猫:

 FATAL EXCEPTION: main
 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.iv.daging/com.iv.daging.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.iv.daging.MainActivity" on path: DexPathList[[zip file "/data/app/com.iv.daging-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.iv.daging-2, /vendor/lib, /system/lib]]
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
    at android.app.ActivityThread.access0(ActivityThread.java:162)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5371)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.iv.daging.MainActivity" on path: DexPathList[[zip file "/data/app/com.iv.daging-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.iv.daging-2, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2260)
    ... 11 more
 FATAL EXCEPTION: main
 java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.iv.daging/com.iv.daging.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "com.iv.daging.MainActivity" on path: DexPathList[[zip file "/data/app/com.iv.daging-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.iv.daging-2, /vendor/lib, /system/lib]]
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2269)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2395)
    at android.app.ActivityThread.access0(ActivityThread.java:162)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5371)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:525)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
    at dalvik.system.NativeStart.main(Native Method)
 Caused by: java.lang.ClassNotFoundException: Didn't find class "com.iv.daging.MainActivity" on path: DexPathList[[zip file "/data/app/com.iv.daging-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.iv.daging-2, /vendor/lib, /system/lib]]
    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
    at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2260)
    ... 11 more

非常感谢兄弟们

大多数时候问题是 类 conflict/not 是最新的。这些是我目前能想到的选项。

  • 检查项目构建路径
  • 清理项目
  • 如果您确实使用了支持库,请将其删除然后再添加回来。
  • 重启 eclipse / android studio

我终于完成了,我只是修复 Jar 不匹配中的依赖项!这是我的解决方案 Jar mismatch! Fix your dependencies