您的位置:首页 > 移动开发 > Android开发

Some jar(v4 support, ActionBarSherlock and etc.) import error in Android Studio

2013-05-19 15:29 381 查看



How to configure ActionBarSherlock with Intellij IDEA

[Original URL:http://android-wtf.com/2012/09/how-to-configure-actionbarsherlock-with-intellij-idea/]

11
Replies


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
Modules
on the left pane

Click on the plus sign above the second column, and choose
Module


Add Module
window will appear. Select the
Create
module from existing sources
option

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
library
subdirectory

Click
OK
to dismiss the dialog

Back in the
Add Module
window, click
Next
as
many times as needed

Click
Finish


Select your application module in the
Modules
pane

Activate the
Dependencies
tab, then click on the plus sign on the right, and select
Module
dependency...


Select the ABS library and click
OK


Finally click
OK
to close the
Project
Structure
window


Step 3: Add Android Support Library

Copy the jar file
<sdk>\extras\android\support\v4\android-support-v4.jar
to your
project’s
libs
directory (create one if it doesn’t exist)

Switch to IDEA

Open
File > Project Structure
if you have closed it

Select
Libraries
from 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
libs
directory

Choose the jar you copied earlier, and click
OK


A popup titled
Choose Modules
will appear

Select both modules, and click
OK


Click
OK
to apply the changes in the
Project
Structure
window


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.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐