'R cannot be resolved to a variable' - gen folder is empty

前端 未结 14 2386
故里飘歌
故里飘歌 2021-02-13 22:34

I\'ve got an error:

R cannot be resolved to a variable

in line:

setContentView(R.layout.main);

but I can\'t r

14条回答
  •  无人及你
    2021-02-13 22:55

    Don't import Android.R;

    instead,

    import package.name.R; where package.name is your package name declared in the manifest.

    Android.R contains all the default layouts packaged with Android. Your custom layout will not be Android.R, it will be in package.name.R;

提交回复
热议问题