2

I am new to android development I have installed SDK in netbeans 7.1.1 . This is the default code which gets generated when i create a new android project in netbeans

package android.bug;

import android.app.Activity;
import android.os.Bundle;

public class MainActivity extends Activity
{
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
  }
}

Default code should be free from errors but i am getting an error in the last line i.e "setContentView(R.layout.main)"

 error is : package R does not exist

But when i import R package in the above code then i get a different error in the same line i.e "setContentView(R.layout.main)"

 error :cannot find symbol : main 
RustyTheBoyRobot
  • 5,891
  • 4
  • 36
  • 55
rick
  • 913
  • 6
  • 13
  • 28

3 Answers3

2

you may have some errors in your res folder.

R.java is auto generated file. It wont create until you solve all your errors from res folder.

for example: error in main.xml

solve all errors, clean your project and

import yourpackagename.R;

see similar problem

Community
  • 1
  • 1
MAC
  • 15,799
  • 8
  • 54
  • 95
0

I specified the android SDK folder in eclipse (Window - Preferences, Android SDK Location) without a trailing \ . So the path to aapt.exe tool was wrong (C:\android-sdk-windowsplatform-tools instead of C:\android-sdk-windows\platform-tools) and the resources not built.

Daniel
  • 21
  • 1
-1

Take a look at this question, it's pretty comprehensive for issues with R files: R cannot be resolved - Android error

Also, Eclipse is the recommended IDE for Android development, you may want to try it.

Community
  • 1
  • 1
Todd Davies
  • 5,484
  • 8
  • 47
  • 71