android - "R cannot be resolved to a variable" error goes away after building project -
i getting "r cannot resolved variable" error of sudden. read thread on issue , says update android build tools make error go away did not fix it. reason error goes away when build project.
what going on here?
i found happening me broken layout. no need worry. trying best giving solution:
solution:
make sure r. links not broken. fix errors in xml files. if in adks broken, r not regenerate.
if somehow hit , created import
android.r
in activity, remove it.run project -> clean. delete , regenerate r , buildconfig.
make sure project -> build automatically ticked. if not, build manually via menu -> project -> build project .
wait few seconds errors disappear.
if doesn't work:
- delete inside /gen/ folder
if still doesn't work:
- try right-clicking project -> android tools -> fix project properties.
check *.properties files (in root folder of app folder) , make sure links in there not broken.
right-click project > properties > android.
look @ project build target , library sections on right side of page. build target should match target in androidmanifest.xml. if it's set target 17 in androidmanifest, make sure target name android 4.2. if library has x under reference, remove , re-add library until there's green tick. might happen if you've moved few files , folders around.
what if r doesn't regenerate
this happens when have broken xml file.
check errors inside xml files, within /res/ folder
common places /layout/ , /values/ if you've changed 1 of them recently
check androidmanifest.xml, find change string, , forget change string name androidmanifest.xml.
check android sdk build-tools installed. window->android sdk manager->tools->android sdk build-tools
make sure when update android sdk tools, update android sdk platform-tools , android ask build-tools. build fails silently if don't match.
if can't find issue:
- right click /gen/ -> restore local history... -> tick r.java -> click restore. doesn't solve problem, clear out errors make problem easier find.
hope you. :)
Comments
Post a Comment