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:
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.
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
Lock Screen Orientation (Android)
Android Emulator Not Able to Access the Internet
Installation App Blocked by Play Protect
Android 4.3 Bluetooth Low Energy Unstable
How to Strike Through Text in an App Widget
Playing a Video in Videoview in Android
Storing Dimensions in Xml File in Android
Error Message 'Java.Net.Socketexception: Socket Failed: Eacces (Permission Denied)'
Running the New Intel Emulator for Android
Embedding Ads Within Recyclerview
How to Strip or Escape HTML Tags in Android