سؤال

I'm making a new android app, and I am using the action bar sherlock library.

I imported the library as a project and got two errors. First, all my layouts are not found in the gen.R file, because I have no gen.R file. "R cannot be resolved to a variable"

Second, I read in some forums that a clean and rebuild can help, but this did not fix my problem. After a clean, I got this error:

[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo'.
[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:47: error: Error: No resource found that matches the given name: attr 'android:actionBarSize'.
[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:48: error: Error: No resource found that matches the given name: attr 'android:actionBarStyle'.
[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:50: error: Error: No resource found that matches the given name: attr 'android:actionBarTabBarStyle'.
[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:49: error: Error: No resource found that matches the given name: attr 'android:actionBarTabStyle'.
[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:51: error: Error: No resource found that matches the given name: attr 'android:actionBarTabTextStyle'.
[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:52: error: Error: No resource found that matches the given name: attr 'android:actionButtonStyle'.
[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:53: error: Error: No resource found that matches the given name: attr 'android:actionDropDownStyle'.
[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:54: error: Error: No resource found that matches the given name: attr 'android:actionMenuTextAppearance'.
[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:55: error: Error: No resource found that matches the given name: attr 'android:actionMenuTextColor'.
[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:56: error: Error: No resource found that matches the given name: attr 'android:actionModeBackground'.
[2011-11-29 12:17:08 - DroidFridge] C:\Users\Felix Wackernagel\Downloads\JakeWharton-ActionBarSherlock-79a1bbc\library\res\values-v11\abs__styles.xml:57: error: Error: No resource found that matches the given name: attr 'android:actionModeCloseButtonStyle'.

...

This XML-Files comes from the ActionBarSherlock Library. The Library as project didn't show an error.

Can anybody help me?

هل كانت مفيدة؟

المحلول 2

The problem was not the Android Version it was the Java Version. Most of the Android library and also Android too, can not handle Java 1.7. I change my project properties and build my project under java 1.6 and it works. Same problem by HoloEverywhere.

نصائح أخرى

Make sure that your project and the imported library use the same Android version.

This is often related to the Android version your project uses, specifically if you import something that is a different version than your project.

For a walkthrough to fix the problem, see my answer here

Please note that to compile an android project successfully and to have it run on older version of android is (mostly) a different thing.

for your answer, android:Theme.Holo is android Honeycomb and above theme. So ActionbarSherlock & your project must be compiled with (minimum) API level 11 (Android 3.0). Usually I just pick ICS (14+)

to have it run on older version of android: open your project manifest file, change the line:

<uses-sdk android:targetSdkVersion="14"/>

to

<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="14"/>

Your android app can run from API level 7 (2.2) to API level 14 (4.0). You can test by running it with 2.2 emulator.

Note that ActionbarSherlock doesn't run with API level lower than 7.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top