Android重启应用程序崩溃:java.lang.InstanceionException:无法实例化类;没有空构造函数

Android重启应用程序崩溃:java.lang.InstanceionException:无法实例化类;没有空构造函数,java,android,android-intent,android-fragments,actionbarsherlock,Java,Android,Android Intent,Android Fragments,Actionbarsherlock,我的Android应用程序在闲置12小时后重启时崩溃 正如崩溃日志告诉我的那样,我一直在尝试到处添加空构造函数,但仍然失败 以下是崩溃日志: E/AndroidRuntime(22225): FATAL EXCEPTION: main E/AndroidRuntime(22225): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.abcde.com/com.abcde.com.HomeActivity

我的Android应用程序在闲置12小时后重启时崩溃

正如崩溃日志告诉我的那样,我一直在尝试到处添加空构造函数,但仍然失败

以下是崩溃日志:

E/AndroidRuntime(22225): FATAL EXCEPTION: main
E/AndroidRuntime(22225): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.abcde.com/com.abcde.com.HomeActivity}: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.abcde.com.BaseSlideActivity$12: make sure class name exists, is public, and has an empty constructor that is public
E/AndroidRuntime(22225):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2080)
E/AndroidRuntime(22225):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2105)
E/AndroidRuntime(22225):    at android.app.ActivityThread.access$600(ActivityThread.java:136)
E/AndroidRuntime(22225):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1201)
E/AndroidRuntime(22225):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(22225):    at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime(22225):    at android.app.ActivityThread.main(ActivityThread.java:4881)
E/AndroidRuntime(22225):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(22225):    at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime(22225):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:804)
E/AndroidRuntime(22225):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:571)
E/AndroidRuntime(22225):    at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime(22225): Caused by: android.support.v4.app.Fragment$InstantiationException: Unable to instantiate fragment com.abcde.com.BaseSlideActivity$12: make sure class name exists, is public, and has an empty constructor that is public
E/AndroidRuntime(22225):    at android.support.v4.app.Fragment.instantiate(Fragment.java:413)
E/AndroidRuntime(22225):    at android.support.v4.app.FragmentState.instantiate(Fragment.java:97)
E/AndroidRuntime(22225):    at android.support.v4.app.FragmentManagerImpl.restoreAllState(FragmentManager.java:1801)
E/AndroidRuntime(22225):    at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:213)
E/AndroidRuntime(22225):    at com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity.onCreate(SlidingFragmentActivity.java:23)
E/AndroidRuntime(22225):    at com.abcde.com.BaseSlideActivity.onCreate(BaseSlideActivity.java:61)
E/AndroidRuntime(22225):    at com.abcde.com.HomeActivity.onCreate(HomeActivity.java:112)
E/AndroidRuntime(22225):    at android.app.Activity.performCreate(Activity.java:5084)
E/AndroidRuntime(22225):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
E/AndroidRuntime(22225):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2044)
E/AndroidRuntime(22225):    ... 11 more
E/AndroidRuntime(22225): Caused by: java.lang.InstantiationException: can't instantiate class com.abcde.com.BaseSlideActivity$12; no empty constructor
E/AndroidRuntime(22225):    at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime(22225):    at java.lang.Class.newInstance(Class.java:1319)
E/AndroidRuntime(22225):    at android.support.v4.app.Fragment.instantiate(Fragment.java:402)
E/AndroidRuntime(22225):    ... 20 more
HomeActivity.java

public class HomeActivity extends BaseSlideActivity implements
    TutorialFragmentListener {
private String TAG = this.getClass().getSimpleName();
public String mLastSelectedMenu = "";
// private Fragment mLastContentFragment = null;
private boolean isRestart;

private MenuData lastMenuData;
private List<String> fragmentNameHistory = new ArrayList<String>();

public int currentOrientation;
public float currentFontScale;
public static boolean isOrientationChanged = false;
public boolean isLanguageChanged = false;
public boolean isJumpToMycoupons = false;
public boolean isLogin;
public BocApplication application;
public FrameLayout layout_post;
public FrameLayout layout_pre;
public RelativeLayout layout_cover;

public static AQuery globalAQuery;
public static boolean isMainPageClicked;

public MenuFragmentAutoHighlighter menuFragmentAutoHighlighter;


boolean testPush = false;


public HomeActivity() {
}

@Override
public void onCreate(Bundle savedInstanceState) {
    mTitleRes = R.string.home;
    super.onCreate(savedInstanceState);

    try {
        MapsInitializer.initialize(getApplicationContext());
    } catch (GooglePlayServicesNotAvailableException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


    menuFragmentAutoHighlighter = new MenuFragmentAutoHighlighter(this);


    Utils.mContext = getApplicationContext();
    Utils.getDisplayImageOptions(this);
    application = (BocApplication) getApplication();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            this).writeDebugLogs().build();

    ImageLoader.getInstance().init(config);

    currentOrientation = getResources().getConfiguration().orientation;
    currentFontScale = getResources().getConfiguration().fontScale;
    // mLastContentFragment = null;
    setContentView(R.layout.activity_home);

    globalAQuery = new AQuery(this);

    layout_post = (FrameLayout) findViewById(R.id.postlogon_content_frame);
    layout_pre = (FrameLayout) findViewById(R.id.content_frame);
    // layout_cover = (RelativeLayout)findViewById(R.id.layout_cover);

    // Loading Mask
    makeLoadingMask();
    prepareOverlayWebView();
    // LoadingMask.getCurrentInstance().flushLoadingView().refresh();


    // VAN: PUSH CHECK SHOULD LAUNCH CERTAIN PAGE HERE!

    if (!checkPushNotificationLaunchPage())
    {   
        Fragment dashboardFragment = ContentFragmentHelper.getContentFragment(
                this, genHomeMenuData());
        changeFragment(dashboardFragment, null);
    }
    initDb();



    findViewById(R.id.view_overlay).setOnTouchListener(
            new OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    return true;
                }
            });



    SlidingMenu sm = getSlidingMenu();
    sm.setOnClosedListener(menuClosedListener);


}
public class BaseSlideActivity extends SlidingFragmentActivity {
protected int mTitleRes;

private View mFrameTitleButton;
private View mFrameEditButton;

private View mLeftMenuButton;
private View mBackButton;
private View mRightMenuButton;

protected View mLoginButton;
protected View mRightDivider;
protected View mDoneButton;
protected TextView mResetButton;
protected TextView mCancelButton;

protected TextView mLoginButtonTitle;
protected TextView mDoneButtonTitle;

public MenuFragment mLeftMenuFragment;
protected RightMenuFragment mRightMenuFragment;

protected ActionBarListener mActionBarDoneListener;
protected ActionBarListener mActionBarResetListener;
protected ActionBarListener mActionBarCancelListener;

public BaseSlideActivity() {
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // isTablet checking
    if (!Utils.isTablet(this)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    initActionBar();
    setTitle(mTitleRes);
    initSlidingMenu(savedInstanceState);
}
public class SlidingFragmentActivity extends SherlockFragmentActivity implements SlidingActivityBase {

private SlidingActivityHelper mHelper;

public SlidingFragmentActivity() {
}

/* (non-Javadoc)
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHelper = new SlidingActivityHelper(this);
    mHelper.onCreate(savedInstanceState);
}

/* (non-Javadoc)
 * @see android.app.Activity#onPostCreate(android.os.Bundle)
 */
@Override
public void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    mHelper.onPostCreate(savedInstanceState);
}
SlidingFragmentActivity.java

public class HomeActivity extends BaseSlideActivity implements
    TutorialFragmentListener {
private String TAG = this.getClass().getSimpleName();
public String mLastSelectedMenu = "";
// private Fragment mLastContentFragment = null;
private boolean isRestart;

private MenuData lastMenuData;
private List<String> fragmentNameHistory = new ArrayList<String>();

public int currentOrientation;
public float currentFontScale;
public static boolean isOrientationChanged = false;
public boolean isLanguageChanged = false;
public boolean isJumpToMycoupons = false;
public boolean isLogin;
public BocApplication application;
public FrameLayout layout_post;
public FrameLayout layout_pre;
public RelativeLayout layout_cover;

public static AQuery globalAQuery;
public static boolean isMainPageClicked;

public MenuFragmentAutoHighlighter menuFragmentAutoHighlighter;


boolean testPush = false;


public HomeActivity() {
}

@Override
public void onCreate(Bundle savedInstanceState) {
    mTitleRes = R.string.home;
    super.onCreate(savedInstanceState);

    try {
        MapsInitializer.initialize(getApplicationContext());
    } catch (GooglePlayServicesNotAvailableException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }


    menuFragmentAutoHighlighter = new MenuFragmentAutoHighlighter(this);


    Utils.mContext = getApplicationContext();
    Utils.getDisplayImageOptions(this);
    application = (BocApplication) getApplication();

    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            this).writeDebugLogs().build();

    ImageLoader.getInstance().init(config);

    currentOrientation = getResources().getConfiguration().orientation;
    currentFontScale = getResources().getConfiguration().fontScale;
    // mLastContentFragment = null;
    setContentView(R.layout.activity_home);

    globalAQuery = new AQuery(this);

    layout_post = (FrameLayout) findViewById(R.id.postlogon_content_frame);
    layout_pre = (FrameLayout) findViewById(R.id.content_frame);
    // layout_cover = (RelativeLayout)findViewById(R.id.layout_cover);

    // Loading Mask
    makeLoadingMask();
    prepareOverlayWebView();
    // LoadingMask.getCurrentInstance().flushLoadingView().refresh();


    // VAN: PUSH CHECK SHOULD LAUNCH CERTAIN PAGE HERE!

    if (!checkPushNotificationLaunchPage())
    {   
        Fragment dashboardFragment = ContentFragmentHelper.getContentFragment(
                this, genHomeMenuData());
        changeFragment(dashboardFragment, null);
    }
    initDb();



    findViewById(R.id.view_overlay).setOnTouchListener(
            new OnTouchListener() {

                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    return true;
                }
            });



    SlidingMenu sm = getSlidingMenu();
    sm.setOnClosedListener(menuClosedListener);


}
public class BaseSlideActivity extends SlidingFragmentActivity {
protected int mTitleRes;

private View mFrameTitleButton;
private View mFrameEditButton;

private View mLeftMenuButton;
private View mBackButton;
private View mRightMenuButton;

protected View mLoginButton;
protected View mRightDivider;
protected View mDoneButton;
protected TextView mResetButton;
protected TextView mCancelButton;

protected TextView mLoginButtonTitle;
protected TextView mDoneButtonTitle;

public MenuFragment mLeftMenuFragment;
protected RightMenuFragment mRightMenuFragment;

protected ActionBarListener mActionBarDoneListener;
protected ActionBarListener mActionBarResetListener;
protected ActionBarListener mActionBarCancelListener;

public BaseSlideActivity() {
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // isTablet checking
    if (!Utils.isTablet(this)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    initActionBar();
    setTitle(mTitleRes);
    initSlidingMenu(savedInstanceState);
}
public class SlidingFragmentActivity extends SherlockFragmentActivity implements SlidingActivityBase {

private SlidingActivityHelper mHelper;

public SlidingFragmentActivity() {
}

/* (non-Javadoc)
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mHelper = new SlidingActivityHelper(this);
    mHelper.onCreate(savedInstanceState);
}

/* (non-Javadoc)
 * @see android.app.Activity#onPostCreate(android.os.Bundle)
 */
@Override
public void onPostCreate(Bundle savedInstanceState) {
    super.onPostCreate(savedInstanceState);
    mHelper.onPostCreate(savedInstanceState);
}
有人能给我一些线索吗

更新日期2014/10/15上午11:00:MenuFragmentAutoHighlighter.java

public class MenuFragmentAutoHighlighter {

public HomeActivity homeActivity;

public MenuFragmentAutoHighlighter(HomeActivity homeActivity)
{
    this.homeActivity = homeActivity;
}

public void tryHighlightMenuItemByBaseFragmentClass(Fragment fragment)
{
    if (homeActivity == null || homeActivity.mLeftMenuFragment == null)
    {
        return;
    }

        homeActivity.mLeftMenuFragment.setSelectedPreMenuItem(
                ContentFragmentHelper.MENU_HOME,
                null);
}
}

BaseSlideActivity的构造函数以及您发布的所有其他构造函数都不应为空,因为此类扩展了SlidingFragmentActivity。 您应该在其中以及扩展其他类的类的所有其他构造函数中添加一个调用:

super.CLASS_NAME(); //a call to the super class's empty constructor

post MenuFragmentAutoHighlighter类注意:无法实例化fragment com.bochk.com.BaseSlideActivity$12,意味着您可能有一个非静态的内部fragment类,如果是,您应该将其设置为静态并尝试一下。我在我的工作区中搜索过,但没有声明内部fragment类,既不是静态的,也不是静态的。BaseSlideActivity$12中的第13个匿名内部类(从0开始计数)是没有参数构造函数的片段。$12-这意味着公共MenuFragment mLeftMenuFragment;受保护的权利碎片Mrightmen碎片;是吗???对不起,它坏了。我早些时候尝试过这个解决方案,但没有明显效果。最终我将onCreatebundle重写为super.onCreatenull