---
title: "Android error - R cannot be resolved"  
description: "Android error - R cannot be resolved"  
author: "Anonymous User"  
published: 2015-05-20  
updated: 2015-05-20  
canonical: https://www.mindstick.com/forum/23244/android-error-r-cannot-be-resolved  
category: "android"  
tags: ["android", "android activity"]  
reading_time: 2 minutes  

---

# Android error - R cannot be resolved

I just downloaded and installed the new [Android](https://www.mindstick.com/articles/13046/10-reasons-why-i-prefer-android-vs-iphone-ios) SDK. I wanted to create a [simple](https://yourviews.mindstick.com/story/1469/5-simple-ways-to-stay-fit-amp-healthy) [application](https://www.mindstick.com/articles/12824/calculator-application-in-android) to [test](https://yourviews.mindstick.com/story/1427/explosive-facts-about-trinity-test-world-s-first-nuclear-bomb) drive it.\
The [wizard](https://answers.mindstick.com/qa/34027/which-sporstman-is-known-as-the-wizard-of-hockey) created this [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):\

```
package eu.mauriziopz.gps;import android.app.Activity;import android.os.Bundle;public class ggps extends Activity {    /** Called when the activity is first created. */    @Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);    }}
```

but Eclipse gives me the [error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing)\
R cannot be resolvedon line\

```
setContentView(R.layout.main);
```

Why?

## Replies

### Reply by Anonymous User

R is an automatically generated class that holds the constants used to identify your >resources. If you don't have an R.java file (it would be gen/eu.mauriziopz.gps/R.java in >Eclipse with the 1.5 SDK) I would recommend closing and reopening your project or going to >Project > Build all (and selecting "Build Automatically" while there as recommended by >Josef). If that doesn't work than try making a new project, if the problem is recreated than >post here again and we'll go into more detail.\
but I've found out that there was another problem that was causing the first one. The tools in the SDK directory didn't have the permissions to be executed, so it was like the didn't exist for Eclipse, thus it didn't build the R.java file.\
So modifying the permission and selecting "Build Automatically" solved the problem\
Each time I had a problem with R not been generated, or even disappeared, this was due to some problem in the XML layout file that prevented the application from being built.\


---

Original Source: https://www.mindstick.com/forum/23244/android-error-r-cannot-be-resolved

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
