android - setContentView(R.layout.main); Gives error from start -
i'm starting develop android, , followed tutorial on google set up. i'm using eclipse , have both android sdk , eclipse plugin installed, when create new android project, error on line start.
public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); } it says "r" in "r.layout.main" not exist. there class need create or import? i'm confused because have thoroughly searched , cannot find else issue.
this quite common mistake . make sure @ top of java file of activity , import not of android.r.layout (or whatever) ,since should import r of own app (which inside gen folder).
if still have problems , try delete gen folder , make sure layout file ok (meaning it's correct android layout file, without mistakes), make sure of resources (all images, sounds , xml files , in /res) have legal characters in files names (which means lowercase english ,optionally "_" , digits, no more) , clean project , , import generated file .
you can use ctrl+1 on red underline of r complains , , choose 1 of project.
Comments
Post a Comment