找不到R文件的问题分很多种,在这边我仅提供我自己解决的方法。
在出现找不到R文件时,有很多情况都是资源文件引入不正确导致的问题,比如图片、String等资源。
而在Android Studio中可以很快定位问题。
解决方法:
如上图,选中Build–>Rebuild Project 之后,编译器自动就会提示你出错的地方,如下:
Error:(47, 21) No resource found that matches the given name (at 'src' with value '@drawable/a_left').
Error:(48, 36) No resource found that matches the given name (at 'contentDescription' with value '@string/start_a').
以上的问题就是图片和string资源找不到才报错的。根据提示找到对应的资源文件修改就可以了。