Introduction
This tutorial will guide you through the steps to set up ActionBarSherlock (ABS from now on) with your Android project created using Intellij IDEA. Just for the record, I’m using ABS version 4.1.0 and IDEA version 11.1.3.
Requirements
- You must target API level 14 (Android 4.0) or higher
- You must install the Android Support Library using SDK Manager, since ABS depends on it
As a rule, you should always target the latest API version to avoid enabling unnecessary compatibility behaviors, to take advantage of the latest platform improvements and optimizations. ABS, in turn, will use the platform’s native ActionBar implementation instead of it’s own backport. As far as ABS is concerned, minimum SDK version can be as low as 7 (Android 2.1).
Step 1: Download ActionBarSherlock
Download and extract ActionBarSherlock, preferably to the same directory where your projects reside. By default, it is C:\Users\<Name>\IdeaProjects on Windows 7.
If you prefer Git, clone and checkout the latest stable version.
Step 2: Create a module with Intellij IDEA
- Switch to IDEA
- Open
File > Project Structure - Select
Moduleson the left pane - Click on the plus sign above the second column, and choose
Module -
Add Modulewindow will appear. Select theCreate module from existing sourcesoption - Click on the button right next to the textbox
- A tree-based directory chooser dialog will pop up. Within the dialog navigate to the ABS directory, and choose the
librarysubdirectory - Click
OKto dismiss the dialog - Back in the
Add Modulewindow, clickNextas many times as needed - Click
Finish - Select your application module in the
Modulespane - Activate the
Dependenciestab, then click on the plus sign on the right, and selectModule dependency... - Select the ABS library and click
OK - Finally click
OKto close theProject Structurewindow
Step 3: Add Android Support Library
- Copy the jar file
<sdk>\extras\android\support\v4\android-support-v4.jarto your project’slibsdirectory (create one if it doesn’t exist) - Switch to IDEA
- Open
File > Project Structureif you have closed it - Select
Librariesfrom the left pane - Click on the plus sign above the second column, and choose
Java - From the file-chooser popup, navigate to your project’s
libsdirectory - Choose the jar you copied earlier, and click
OK - A popup titled
Choose Moduleswill appear - Select both modules, and click
OK - Click
OKto apply the changes in theProject Structurewindow
Conclusion
That’s it. You should now be able to use ActionBarSherlock in your project. Just don’t forget to extend the SherlockActivity class instead of the native Activity class. If anything goes wrong, let me know in the comments.
本文指导您如何将ActionBarSherlock设置为使用IntelliJ IDEA创建的Android项目的一部分,包括下载、模块创建、添加Android Support Library等步骤。






