Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialShane McC
3,005 PointsR cannot be resolved to Variable error, missing R.java?
Hi Everyone
I just recently upgraded my eclipse software. I'm getting this error in every single file for my app "R cannot be resolved to a variable". I'm also missing the R.java file from my gen folder. I know I need my R.java file for my app to work. My question is, how would I get my app running properly again? How should I fix this problem?
I would also like to add two of my XML files have errors.
Error 1 In folder called values-v11 styles.xml I'm getting an error called "Error: retrieving parent for item. No resource found that matches the given name android:Theme.Holo.Light.DarkActionBar"
Error 2 In folder called values-v14 styles.xml I'm getting an error called "Error: retrieving parent for item. No resource found that matches the given name android:Theme.Holo.Light.DarkActionBar"
Thanks
3 Answers
Bernardo Simões
3,233 PointsHmm... Did you change your android manifest? Whats your minSdkVersion? It might not be compatible with the Hole Theme.. Did you check that?
Shane McC
3,005 Points Hi Everyone
I finally figured out the problem. I had to delete this line of code from my main.xml syntax
android:showAsAction="never"
Under my values-v11 and values-14 folders I changed the name of the app to
style name="AppBaseTheme" parent="android:Theme.Light"
and it's currently working
Bernardo Simões
3,233 PointsI had that error before.. Even though I don't have eclipse and android sdk installed right now to tell each step you need to do, basically you just need to rebuild your project. Also check out this link: http://stackoverflow.com/questions/7824730/r-cannot-be-resolved-to-a-variable
Shane McC
3,005 PointsBernardo, I've since added to my question. I think the problem might lay in a few of my XML files. I've rebuilt my project before but that didn't work.
Shane McC
3,005 PointsBernardo
Below is my syntax for the android manifest. My minSdkVersion is 8.
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
I've since renamed my styles.xml files to <style name="AppBaseTheme" parent="android:Theme.Light"> and that has seemed to correct the program regarding those two files but I'm still getting the R cannot be resolved to Variable error on every file in my app. Any help would be appreciated. Thanks
When I rebuild my project I'm getting this error in my console [2014-03-16 10:48:45 - ThisIsATestProject] W/ResourceType( 5756): ResXMLTree_node header size 0 is too small. [2014-03-16 10:48:45 - ThisIsATestProject] C:\workspace\ThisIsATestProject\res\menu\main.xml:3: error: No resource identifier found for attribute 'showAsAction' in package 'android'
Below is my entire manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.thisisatestproject"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".Splash"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.thisisatestproject.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.thisisatestproject.STARTINGPOINT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.example.thisisatestproject.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".AboutUs"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog"
>
<intent-filter>
<action android:name="com.example.thisisatestproject.ABOUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Prefs"
android:label="@string/app_name"
android:theme="@android:style/Theme.Dialog"
>
<intent-filter>
<action android:name="com.example.thisisatestproject.PREFS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".TextPlay"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Email"
android:label="@string/app_name" >
</activity>
<activity
android:name=".Camera"
android:label="Camera App"
android:screenOrientation="portrait"
>
</activity>
<activity
android:name=".Data"
android:label="Camera App"
android:screenOrientation="portrait"
>
</activity>
<activity
android:name=".GFX"
android:label="Camera App"
android:screenOrientation="portrait"
>
</activity>
<activity
android:name=".GFXSurface"
android:label="Camera App"
android:screenOrientation="portrait"
>
</activity>
<activity
android:name=".SoundStuff"
android:label="Camera App"
android:screenOrientation="portrait"
>
</activity>
<activity
android:name=".PlayMusic"
android:label="Play Music"
android:screenOrientation="portrait"
>
</activity>
<activity
android:name=".ChooseMusic"
android:label="Play Music"
android:screenOrientation="portrait"
>
</activity>
<activity
android:name=".Slider"
android:label="Play Music"
android:screenOrientation="portrait"
>
</activity>
<activity
android:name=".OpenedClass"
android:label="Camera App"
android:screenOrientation="portrait"
>
</activity>
</application>
</manifest>
Shane McC
3,005 PointsShane McC
3,005 PointsI've since renamed my styles.xml files to <style name="AppBaseTheme" parent="android:Theme.Light"> and that has seemed to correct the program regarding those two files but I'm still getting the R cannot be resolved to Variable error on every file in my app. Any help would be appreciated. Thanks