10

I just downloaded Android Developer Tools (ADT), which includes Eclipse, etc., and I followed Android's guide to create MyFirstApp. I've just spend over an hour looking for

android-support-v7-app.jar

but was unable to. Do you have any suggestions on how to handle the fact that for a blank template, android.support.v7.app.ActionBarActivity not resolve.

user3659451
  • 1,913
  • 9
  • 30
  • 43

3 Answers3

44

The use of ActionBarActivity is now deprecated, use

import android.support.v7.app.AppCompatActivity

your class now must 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

Jorgesys
  • 124,308
  • 23
  • 334
  • 268
8

Make sure you've downloaded the package android.support.v7. Then, Import the whole appcompat lib (/extras/android/support/v7/appcompat) as a library project to your workspace and then add to your main project as a library:

Here are the steps.

First check if android-support-v7-appcompat is already in your workspace. If it is go to Step 2

Step 1:

Select File > Import.

Select Existing Android Code Into Workspace and click Next.

Browse to the SDK installation directory and then to the Support Library folder. /extras/android/support/v7/appcompat/.

Click Finish to import the project. For the v7 appcompat project, you should now see a new project titled android-support-v7-appcompat.

Step 2:

Right-click on your project -> Properties In Android->Library section click Add Select android-support-v7-appcompat -> Ok

Community
  • 1
  • 1
Nana Ghartey
  • 7,901
  • 1
  • 24
  • 26
4

The use of ActionBarActivity and v7 is outdated now and is no longer supported by latest versions of Android Studio.

To correct the error simply replace

import android.support.v7.app.ActionBarActivity; 

with

import androidx.appcompat.app.AppCompatActivity;

and also replace the parent class ActionBarActivity with AppCompatActivity

For example: (old and not working): public class MainActivity extends ActionBarActivity with (new): public class MainActivity extends AppCompatActivity

Benjamin Zach
  • 1,452
  • 2
  • 18
  • 38