Home » Android » android – Why was ActionBarActivity deprecated

android – Why was ActionBarActivity deprecated

Posted by: admin March 11, 2020 Leave a comment


I installed Android Studio freshly and I begun coding an activity to extend ActionBarActivity and it showed that it was deprecated. So how else do I set up an actionbar for my activity.
Also the Getting Started Training uses the ActionBarActivity without making reference that it has been deprecated.

How to&Answers:

ActionBar is deprecated ever since Toolbar was introduced. Toolbar can be seen as a ‘superset’ of any action bar. So the ‘old’ ActionBar is now an example of a Toolbar. If you want similar functionality, but without deprecation warnings do the following:

Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
if (toolbar != null) {

You need to define the Toolbar in your layout xml:


With this new functionality you can create your own custom ActionBar and let Android do the heavy lifting. Just create your own custom view that extends from Toolbar.

Also, you should use AppCompatActivity instead of ActionBarActivity, it was introduced in the latest version of the appcompat library. So dont forget to update gradle

compile 'com.android.support:appcompat-v7:22.1.1'


Here is the answer from the post in Android developers blog:

“ActionBarActivity has been deprecated in favor of the new AppCompatActivity.

You can read more about it there.


This answer give a simple way to Eliminate the error message.
You can see as an add to others’.

When we change the parent Activity class: ActionBarActivity to AppCompatActivity the error message will disappear.

You can click here for more info.