I have had an issue reported to me by a couple of users.
My app simply crashes when they try and launch it, they are using Samsung Galaxy S8+ and S9, Android 8.0.
Here is the exception:
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)
Here are the onCreate methods for BaseActivity, CommonActivity and TipsActivity:
Base
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
_context = this;
_vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
_handler = new Handler(this);
}
Common
@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() {
}
});
}
Tips
@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);
}
}
});
}
I have tried this in the 8.0 emulator in Android Studio but cannot reproduce the error but do need to try and fix if possible.
Does anyone have any ideas?
FURTHERMORE
If i go into onCreate on BaseActivity it takes me to AppCompatActivity and the following code:
@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);
}