Cannot Resolve @style/theme.sherlock
Solution 1:
The pitfall I encountered was this: The reference to the ActionBarSherlock project needs to be in the Android->Libraries section of the project properties, while I had been adding it to the Build Path->Libraries.
Solution 2:
I encountered a strange anomaly that might help!
Have built android project that uses ABS, running it on Gingerbread works fine, in ICS it crashes, the crash under ICS occurs due to this, check your AndroidManifest.xml (have trimmed out bits for brevity...
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" android:theme="@style/Theme.Sherlock">
It was the android:theme part that caused the crash under ICS, it worked fine under Gingerbread and older versions!. Solution was to remove it completely! Then from your Activity, do this:
@OverridepublicvoidonCreate(Bundle savedInstanceState) {
if (Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.ICE_CREAM_SANDWICH){
this.setTheme(com.actionbarsherlock.R.style.Theme_Sherlock);
}
super.onCreate(savedInstanceState);
... // MORE CODE ....
}
This fixed up the crash under ICS, the theme style is not liked by ICS, but it works fine for both versions less than 2.3 and 4.0 upwards.. weird error but that I discovered by fluke!
Remember to apply the theme before calling the base class's own onCreate!
Solution 3:
My standard procedure for including a library project on Eclipse goes like this:
- Import library project
- Right click on library project Properties -> Android -> Set Project Build Target (insure library and primary project are the same)
- Right click on library project Android Tools -> Fix Project Properties
- Select the library project then Project -> Clean...
- Select primary project then Project -> Clean...
That should fix whatever ails you.
Solution 4:
I finally find the solution:
- IMPORTANT! Copy the same android-support-v4.jar in both projects: in library and your project (this is the principal problem).
- Import "library" project TO YOUR WORKSPACE
- Right click on library project Properties -> Android -> Check "Target Name" 4.x (any, API level 14,15 or 16). Bottom check "Is library".
- In properties, go to "Java Build Path", tab "Libraries" And find "android-support-v4.jar" normally in "Android Dependencies". Ok and Close Properties.
- Right click on library project Android Tools -> Fix Project Properties
- in Menu Project -> Clean... and select to clean the "Library" Project.
In this place, your project "library" must to be done (without errors)
- Create or import your own project. Example "MyProject"
- In properties, go to "Java Build Path", tab "Libraries" And find "android-support-v4.jar" normally in "Android Dependencies".
- Now go to "Projects" Tab. Add... and select "library" project.
- Now in properties go to Android -> Check "Target Name" 4.x (any, API level 14,15 or 16). IMPORTANT: Must to be the same of "library" project. Bottom "Is Library" must to be UNCHECKED and in this place press Add... And select "library" project. Ok and Close properties.
- Right click on "MyProject" project Android Tools -> Fix Project Properties
- in Menu Project -> Clean... and select to clean the "MyProject" Project.
Already, your project must to be done. If the error persist, restart Eclipse.
Solution 5:
I resolved this issue by the follwoing 2 steps on my projects:
- Remove the "library" from "project properties"/build path and add library in "project properties"/Android/Library
- Right Click on project "Android Tools" -> "Add support library"
Post a Comment for "Cannot Resolve @style/theme.sherlock"