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 {
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
.
Class Activity extends ActionBarActivity deprecated
Do i do something with it? or just leave it alone?
Either is fine. If you wish to get rid of the deprecation warning, replace ActionBarActivity
with AppCompatActivity
. Hopefully, the new-activity templates will be fixed in an upcoming release of Android Studio.
i tried to replace the ActionBarActivity with AppCompatActivity but it gives me errors in the rest of the class.
Make sure that you add the import
statement to import AppCompatActivity
. This directory contains several sample projects that use appcompat-v7
and AppCompatActivity
.
Beyond that, consider asking a separate Stack Overflow question, where you provide your code and list the errors.
cannot resolve symbol ActionBarActivity in android studio 2.1.1
Solution of this kind of problem:
Download the Android Support Repository from Android SDK Manager, SDK Manager icon will be available on Android Studio tool bar (or
Tools -> SDK Manager
).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)
- If you have done all steps or all are present already then u can change the extends as
AppBarActivity
toAppCompatActivity
(Public Class ClassName extends AppCompatActivity)
because AppBarActivity has been deprecated.
Related Topics
Close Application and Remove from Recent Apps/
How to Cancel an Dialog Themed Like Activity When Touched Outside the Window
How to Run Countdowntimer in a Service in Android
Work Around Canvas.Clippath() That Is Not Supported in Android Any More
Create New Project on Android, Error: Studio Unknown Host 'Services.Gradle.Org'
Adb Connection by Wifi Getting Killed When a New Usb Attached/Detached
Add Views Below Toolbar in Coordinatorlayout
Android - Startactivityforresult Immediately Triggering Onactivityresult
Redirecting Audio/Creating Alternate Sound Paths in Android
Converting Activity into Fragment
Android: Get Height of a View Before It's Drawn
How to Get Multiple Icons to Launch Different Activities in One Application
Android: How to Open Another App from My App
How to Handle Outofmemoryerror
How to Get the Fragment Instance from the Fragmentactivity
Upgrade Realm in an Android Project
Recyclerview Gridlayoutmanager: How to Auto-Detect Span Count