I recently installed NetBeans 7.1.1 with NBAndroid 1.11 plugin. After starting a new HelloWorld project, I get the following error from the test code:
C:\Users\Daniel\Documents\NetBeansProjects\HelloWorld\src\Hello\World\HelloWorldMain.java:14: error: cannot find symbol setContentView(R.layout.main);
Here is my source code for HelloWorldMain.java file:
package Hello.World;
import android.R;
import android.app.Activity;
import android.os.Bundle;
public class HelloWorldMain extends Activity
{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
The setContentView function is causing the problem for some reason. I checked the R.java file for any errors and didn't seem to find any:
/* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package Hello.World;
public final class R {
public static final class attr {
}
public static final class layout {
public static final int main=0x7f020000;
}
public static final class string {
public static final int app_name=0x7f030000;
}
}
Any help would be appreciated.
You need to remove import android.R;
. Your R
and android.R
are two different classes.
In Android, we dont have a class that is auto-generated, so, if you doesnt find your R class try to build your project or to run it. After that you can find that a new package was added to your project, there is where you can find your R class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With