user1623228
user1623228

Reputation: 31

Getting errors in android development "R cannot be resolved to a variable" and in layout also

I just started android programming and i am stuck in this problem from many days , whenever i start a new project every time i get these 5 errors , i don't know what to do with them , i tried setting up whole SDK and eclipse setup but still i get these errors , Any one know about how to get rid of theses ???

  1. R cannot be resolved to a variable
  2. Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light.DarkActionBar',styles.xml/example/res/values-v14line 3 Android AAPT Problem
  3. Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Light'.styles.xml/example/res/values line 3 Android AAPT Problem
  4. Error retrieving parent for item: No resource found that matches the given name 'android:Theme.Holo.Light'.styles.xml/example/res/values-v11 line 3 Android AAPT Problem

Upvotes: 3

Views: 5291

Answers (4)

iceman
iceman

Reputation: 826

For those stumbling upon this question, here's a solution: In your project.properties, change target=android-x where x < 11 to some x >= 11 e.g target=android-14, because holo was introduced first in android-11 (Honeycomb).

EDIT:

Correction, x>=14 for android:Theme.Holo.Light.DarkActionBar to work.

Upvotes: 5

Aerrow
Aerrow

Reputation: 12134

For error number 2,3 and 4. In your styles.xml file remove the parent="android:Theme", i used in following way

styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="CustomWindowTitleBackground">

    </style>


    <style name="MyTheme" parent="android:Theme">
        <item name="android:windowTitleSize">65dip</item>
        <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
    </style>
</resources>

May i hope this will be solve your First Error. Incase your first error wont clear means, just clean the your application and then run it.

Upvotes: 1

Malachi
Malachi

Reputation: 3231

when you add a resource to the project you have to update the XML Files associated with it. it will be in a folder probably named res in that folder will be several other folders called drawable layout and values they have XML Files inside them that need to be updated when you ad a resource such as a picture or a string to your project.

I might have the folders wrong, it has been a while since I programmed in Android.

Upvotes: 0

Shubham
Shubham

Reputation: 820

Clean your project: Project->Clean

Also, make sure you did not import "android.R". Eclipse tends to add this sometimes when you manage the imports.

Upvotes: 0

Related Questions