奥利奥:java.lang.IllegalStateException

时间:2018-09-20 10:17:38

标签: java android

我有几个用户向我报告了一个问题。

我的应用程序使用三星Galaxy S8 +和S9,Android 8.0时,它们只是在尝试启动时崩溃。

这里是例外:

java.lang.RuntimeException: 
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2955)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3030)
  at android.app.ActivityThread.-wrap11 (Unknown Source)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1696)
  at android.os.Handler.dispatchMessage (Handler.java:105)
  at android.os.Looper.loop (Looper.java:164)
  at android.app.ActivityThread.main (ActivityThread.java:6938)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)
Caused by: java.lang.IllegalStateException: 
  at android.app.Activity.onCreate (Activity.java:1038)
  at android.support.v4.app.FragmentActivity.onCreate (FragmentActivity.java:278)
  at android.support.v7.app.AppCompatActivity.onCreate (AppCompatActivity.java:84)
  at com.capital6games.i_do.base.BaseActivity.onCreate (BaseActivity.java:34)
  at com.capital6games.i_do.base.CommonActivity.onCreate (CommonActivity.java:67)
  at com.capital6games.i_do.tips.TipsActivity.onCreate (TipsActivity.java:28)
  at android.app.Activity.performCreate (Activity.java:7183)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1220)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2908)

以下是BaseActivity,CommonActivity和TipsActivity的onCreate方法:

基础

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

            _context = this;

            _vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
            _handler = new Handler(this);
        }

常见

    @Override
        public void onCreate(Bundle savedInstanceState){
            super.onCreate(savedInstanceState);
            cartHandler = new ShoppingCartHandler();

            interstitialAd = new InterstitialAd(this);
            interstitialAd.setAdUnitId(AD_UNIT_ID_INTERSTITIAL);
            interstitialAd.setAdListener(new AdListener() {
                @Override
                public void onAdLoaded() {
                    showAd();
                }

                @Override
                public void onAdClosed() {

                }
            });
        }

提示

@Override
    public void onCreate(Bundle bundle)
    {
        super.onCreate( bundle );
        setContentView( R.layout.activity_tips);
        mImageViewPager = (ViewPager) findViewById(R.id.pager);
        check_tips = (CheckBox) findViewById(R.id.check_tips);
        TabLayout tabLayout = (TabLayout) findViewById(R.id.tabDots);
        tabLayout.setupWithViewPager(mImageViewPager, true);
        ArrayList<TipsEntity> arrayListTipsEntity = new ArrayList<>();
        tipFor=getIntent().getStringExtra(Constants.ADMINTIP);
        arrayListTipsEntity=getList();
        TipsViewPagerAdapter tipsViewPagerAdapter=new TipsViewPagerAdapter(TipsActivity.this,arrayListTipsEntity);
        mImageViewPager.setAdapter(tipsViewPagerAdapter);
        ImageView imageClose= (ImageView) findViewById(R.id.imageClose);
        imageClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        check_tips.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(check_tips.isChecked()) {
                    sharedpreferences().put(PrefConst.PREFKEY_SETTING_SHOW_TIPS, false);
                }else{
                    sharedpreferences().put(PrefConst.PREFKEY_SETTING_SHOW_TIPS, true);
                }
            }
        });
    }

我已经在Android Studio的8.0模拟器中尝试过此操作,但无法重现该错误,但需要尝试并进行修复。

有人有什么想法吗?

更多信息

如果我在BaseActivity上进入onCreate,它将带我到AppCompatActivity和以下代码:

@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        final AppCompatDelegate delegate = getDelegate();
        delegate.installViewFactory();
        delegate.onCreate(savedInstanceState);
        if (delegate.applyDayNight() && mThemeId != 0) {
            // If DayNight has been applied, we need to re-apply the theme for
            // the changes to take effect. On API 23+, we should bypass
            // setTheme(), which will no-op if the theme ID is identical to the
            // current theme ID.
            if (Build.VERSION.SDK_INT >= 23) {
                onApplyThemeResource(getTheme(), mThemeId, false);
            } else {
                setTheme(mThemeId);
            }
        }
        super.onCreate(savedInstanceState);
    }

0 个答案:

没有答案