Actionbaractivity Is Deprecated

Why was ActionBarActivity deprecated

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) {
toolbar.setTitle(R.string.app_name);
setSupportActionBar(toolbar);
}

You need to define the Toolbar in your layout xml:

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>

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'

ActionBarActivity is deprecated

Since the version 22.1.0, the class ActionBarActivity is deprecated. You should use AppCompatActivity.

Read here and here for more information.

android.support.v7.app.ActionBarActivity is deprecated

Use

android.support.v7.app.AppCompatActivity

instead of

android.support.v7.app.ActionBarActivity (DEPRECATED)

and extends AppCompatActivity

    public myClass extends AppCompatActivity{
...
...

if you have the message:

cannot resolve symbol AppCompatActivity

You have to update to the last support library in your Android SDK Manager

ActionBarActivity is deprecated Eclipse

Replace ActionBarActivity with AppCompatActivity.

You don't need to do anything, just because it's deprecated doesn't mean it's not functional. It means it will not be supported in the future. Eclipse should be giving you a warning, not an error.

Here's the current souce code of ActionBarActivity, from the Android source code:

/**
* @deprecated Use {@link android.support.v7.app.AppCompatActivity} instead.
*/
@Deprecated
public class ActionBarActivity extends AppCompatActivity {
}

To clarify, all you need to do is replace

public class MainActivity extends ActionBarActivity {

with

public class MainActivity extends AppCompatActivity {

cannot resolve symbol actionbaractivity

ActionBarActivity is deprecated for a long time. And your import statement suggests to use AppCompatActivity instead:

public class Game extends AppCompatActivity {

cannot resolve symbol ActionBarActivity in android studio 2.1.1

Solution of this kind of problem:

  1. Download the Android Support Repository from Android SDK Manager, SDK Manager icon will be available on Android Studio tool bar (or Tools -> SDK Manager).

  2. then go in to extras and download Android support repository
    Then

Open your main module's build.gradle file and add following dependency for using action bar in lower API level

dependencies {
compile 'com.android.support:appcompat-v7:+'
}

Sync your project with gradle using the tiny Gradle icon available in toolbar (or Tools -> Android -> Sync Project With Gradle Files)


  1. If you have done all steps or all are present already then u can change the extends as
    AppBarActivity to AppCompatActivity (Public Class ClassName extends AppCompatActivity) because AppBarActivity has been deprecated.

Android Studio: ActionBarActivity becomes deprecated when adding a dependency?

You need to used ActionBarActivity or Activity.

Theme.Material is only available on devices running API 21 (Lollipop) and up. If you wish to use the Material theme on devices running API 20 and below, you need to use AppCompat.

When I created a new activity, it extends ActionBarActivity but it's deprecated.

This is a very recent change. As of version 22.1 of AppCompat, ActionBarActivity has been deprecated in favor of AppCompatActivity.

Alternative of ActionbarActivity for ToolBar in android

Extend AppCompatActivity instead of ActionbarActivity... That's the new way after ActionbarActivity was deprecated.



Related Topics



Leave a reply



Submit