Cannot resolve findViewByID in AppCompatActivity

浪尽此生 提交于 2019-12-06 09:52:50

You appear to be running into the corrupt cache bug in Android Studio.

This happens to me a LOT when adding custom views with a custom namespace. If you added any custom views, this could be your issue.

To fix: File > Invalidate Caches / Restart

That should reindex everything and allow for auto-completion to work, as well, your findViewById() should work. I reviewed the code and do not see any errors.

AppCompatActivity extends FragmentActivity which extends Activity which has findViewById() method.

So it shouldn't be a problem to get the method.

I believe it's IDE bug. Try to close your IDE and reopen the project. Worked for me, perfectly.

Update your build tools version to the latest 27.0.3, after trying all solutions this is what worked for me.

in app -> build.gradle

buildToolsVersion '27.0.3'

rebuild and hope it works for you too

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!