NullPointerException: with ActionBar.setDisplayHomeAsUpEnabled(boolean)’ on a null object reference

The cause of your issue is using MainActivity extend Activity with support theme style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar". It’s incompatible things.
Which min sdk you need?

In your code having MainActivity extends Activity you don’t need AppCompatTheme. Use name="AppTheme" parent="android:Theme.Light

If you are using Theme.AppCompat.Light.DarkActionBar, you should extend your Activity from AppCompatActivity, and use getSupportActionBar().

Instead of:

public class MainActivity extends Activity {

use:

public class MainActivity extends AppCompatActivity {

and instead of:

getActionBar().setTitle(mTitles);

use:

getSupportActionBar().setTitle(mTitles);

Leave a Comment