2013年8月12日星期一

Android R cannot be resolved to a variable

I created an android project, found gen directory is empty. I do not know why, experts urged.
------ Solution ---------------------------------------- ----
almost two days here, a new colleague sent encountered
1.clean finished compiling look under there
2. ADT plugin is not installed there may be full (build tools)
3. might have the wrong code
------ Solution ------------------------------ --------------

wrong, does not seem to ADT
you open sdk manager, look the build tools are not installed
------ For reference only ------------------- --------------------
1, I clean it several times, still does not compile. Because gen directory is empty.
3, the code can not be wrong, because I was an empty new project, the default code:
public class MainActivity extends Activity {

@ Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main) ;/ / R cannot be resolved to a variable
}


@ Override
public boolean onCreateOptionsMenu (Menu menu) {
/ / Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater (). inflate (R.menu.main, menu) ;/ / R cannot be resolved to a variable
return true;
}

}
It seems that only may be 2, ADT plugin is not installed fully. Then I ask, how to know there is no full installation of the ADT plugin do?
------ For reference only -------------------------------------- -
I saw Tools Here are three:
Android SDK Tools
Android SDK Platform-Tools
Android SDK Build-Tools
I installed the first two, the third is not installed.


------ For reference only ---------------------------------- -----
install Android SDK Build-Tools after, gen directory produces a BuildConfig.java file, but still no R.java it?
------ For reference only -------------------------------------- -
However, the good news is this: I re-create a project, compile, and also generate R.JAVA files. Thank you!
generated by new projects seems R cannot be resolved to a variable of the problem, not only because of the Internet, said ADT update problem, there is no SDK Manager installed inside the whole, especially :
Android SDK Tools
Android SDK Platform-Tools
Android SDK Build-Tools
This 3 must be installed.

没有评论:

发表评论