import .R cannot be resolved when I import actionbarsherlock

后端 未结 3 1177
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 14:26

I want to be able to use the action bar in my android project (2.3), so I am trying to import the actionbarsherlock library. However, I am having problems....

I\'ve

相关标签:
3条回答
  • 2020-11-30 14:56

    edited the build path of my android project to include the library

    Never manually modify the build path of an Android project.

    ActionBarSherlock is an Android library project. You need to add a reference to ActionBarSherlock's library project from your main application project and undo the manual change to the build path.


    UPDATE

    The second half of your problem was that your build target was set too low. The build target controls what version of the Android classes, resources, etc. is available to your app, and if you use ActionBarSherlock, you need this to be API Level 14 or higher.

    if I make my project build target 4.0, can I still run it on an emulator/phone running Android 2.3?

    Yes. Set your android:minSdkVersion to be 10 or lower. Eclipse (via Lint) will yell at you if you accidentally try using classes, methods, and such that are higher than your minSdkVersion, even though they are legal due to your build target.

    0 讨论(0)
  • 2020-11-30 15:00

    ActionBarSherlock is a library project.

    So import the library project in your eclipse

    enter image description here

    Its a library project. To check Right Click on your library project. goto Properties.

    Choose android. You will see a Is Library checked as shown in the below pic.

    enter image description here

    Add your library project to your Android project.

    Right click on your Android project. Goto Properties . Choose android . Click add button add the library to your project. You can see a green tick in the below pic.

    enter image description here

    Make sure you have one copy of andorid-suuport-v4.jar in your libs folder.

    Do not import R.*;

    You will see two R.java one for the library project and one for your android project. Clean and build.

    enter image description here

    0 讨论(0)
  • 2020-11-30 15:10

    I found that if minSDKVersion in AndroidManifest.xml of the Project is lower than library, it also make the Project to be error to build R.java

    0 讨论(0)
提交回复
热议问题