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

來源:互聯網
上載者:User
How to configure ActionBarSherlock with Intellij IDEA[Original URL:http://android-wtf.com/2012/09/how-to-configure-actionbarsherlock-with-intellij-idea/]11
RepliesIntroduction

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
  1. Switch to IDEA
  2. Open File > Project Structure
  3. Select Modules on the left pane
  4. Click on the plus sign above the second column, and choose Module
  5. Add Module window will appear. Select the Create
    module from existing sources
     option
  6. Click on the button right next to the textbox
  7. A tree-based directory chooser dialog will pop up. Within the dialog navigate to the ABS directory, and choose the library subdirectory
  8. Click OK to dismiss the dialog
  9. Back in the Add Module window, click Next as
    many times as needed
  10. Click Finish
  11. Select your application module in the Modules pane
  12. Activate the Dependencies tab, then click on the plus sign on the right, and select Module
    dependency...
  13. Select the ABS library and click OK
  14. Finally click OK to close the Project
    Structure
     window
Step 3: Add Android Support Library
  1. 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)
  2. Switch to IDEA
  3. Open File > Project Structure if you have closed it
  4. Select Libraries from the left pane
  5. Click on the plus sign above the second column, and choose Java
  6. From the file-chooser popup, navigate to your project’s libs directory
  7. Choose the jar you copied earlier, and click OK
  8. A popup titled Choose Modules will appear
  9. Select both modules, and click OK
  10. 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.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.