user3364963
user3364963

Reputation: 397

Android support v7 ActionBarActivity

I am trying to import the Support v7 library to get ActionBarActivity however it is not working. I am unable to extend ActionBarActivity.

I followed the tutorials of adding the support library in from these links

https://developer.android.com/tools/support-library/setup.html

http://hmkcode.com/add-actionbar-to-android-2-3-x/

I followed these line by line however i cannot import android.support.v7.app.ActionBarActivity; it seems to not exist. All i can import is android.support.v7.app.appcompat.R;

I am using Eclipse

Can someone help me out please. Many Thanks!.

This is the summary of what I have done which is working now

  1. Went to SDK manager. Checked that I have the latest Android Support Library ( I have Rev 20). I did not install Support Repository as this is for android studio

  2. Imported existing code into workspace. Selected sdk/extras/android/support/v7/appcompat/. I did NOT check copy to workspace.

  3. right-click each .jar file and select Build Path > Add to Build Path. For example, when creating the the v7 appcompat project, add both the android-support-v4.jar and android-support-v7-appcompat.jar files to the build path.

  4. Right-click the library project folder and select Build Path > Configure Build Path. In the Order and Export tab, check the .jar files you just added to the build path, so they are available to projects that depend on this library project. For example, the appcompat project requires you to export both the android-support-v4.jar and android-support-v7-appcompat.jar files. Uncheck Android Dependencies.

  5. what I did differently was Create a new Android project rather than using an existing. By default it seemed to extend ActionBarActivity automatically since I put min SDK to API 8. What it also did was actually do all the steps above for me! I see new project in my work space appcompat-v7

  6. The only problem I see is on console it said something like unable to write Java cache. I lost the message but I will post it

Upvotes: 0

Views: 602

Answers (2)

someguy234
someguy234

Reputation: 559

You can create a new Project(if possible) with the viewpager activity and select actionbar in the settings. This will automatically import it into your NEW project. If you can copy your old files that'd be great.

Upvotes: 1

Alécio Carvalho
Alécio Carvalho

Reputation: 13657

You basically have to:

  1. Import the android-support-v7-appcompat to your Eclipse as described on these links you read.
  2. Link your own project with 'android-support-v7-appcompat' by going to Project Properties / Android/ Add the 'android-support-v7-appcompat' under the 'Library' section (there's a 'Add' button).

Upvotes: 0

Related Questions