-2

i m beginner in android app development. in android studio when i creat a new project , my main activity class does not extend the action bar activity class. i mean there is written that main Activity class extends action bar activity but there appears a ---(dash) on the actionbaractivity. and shows the error that android.support.v7.app.ActionBarActivity is deprecated. i cant find the solution for this. please help me.

Nishtha patel
  • 39
  • 1
  • 4
  • 1
    Then extends `AppCompatActivity` – M D Jun 16 '15 at 12:56
  • entends AppCompatActivity there – Rishi Paul Jun 16 '15 at 12:56
  • [http://blog.xamarin.com/android-tips-hello-appcompatactivity-goodbye-actionbaractivity/](http://blog.xamarin.com/android-tips-hello-appcompatactivity-goodbye-actionbaractivity/) – M D Jun 16 '15 at 12:58
  • Nishtha, try with this , public class YOURCLASSNAME extends ActionBarActivity and integrate appcompat 7 properly to your project. – Pratik Dasa Jun 16 '15 at 12:58
  • write this lines in your build.gradle file, dependencies { compile fileTree(dir: 'libs', include: '*.jar') compile 'com.android.support:appcompat-v7:21.0.0' } – Pratik Dasa Jun 16 '15 at 12:59
  • [http://stackoverflow.com/questions/29797172/whats-the-enhancement-of-appcompatactivity-over-actionbaractivity](http://stackoverflow.com/questions/29797172/whats-the-enhancement-of-appcompatactivity-over-actionbaractivity) – M D Jun 16 '15 at 12:59

3 Answers3

0

ActionBarActivity is depreciated for sdk version 22 and above, so you need to use AppCompatActivity instead of ActionBarActivity. Rest of your code will be same.

Saptak Niyogi
  • 240
  • 2
  • 10
0

AcitonBarActivity is deprecated starting from version 22.1.0 of the support library.

Take a look at the following link: http://developer.android.com/tools/support-library/index.html
Android Support Library, revision 22.1.0 (April 2015) - Section "Changes for v7 appcompat library"

Now you need to use AppCompatActivity, so extend your Activity from this class and the warning will disappear.

If you look at the build.gradle of you app module you will see the exact version of the support libraries you're using.

fasteque
  • 4,309
  • 8
  • 38
  • 50
-1

import android.support.v7.app.ActionBarActivity; //delete it import androidx.appcompat.app.AppCompatActivity; // use this

extends ActionBarActivity // delete this extends AppCompatActivity // use this