解决Android.content.res.Resources$NotFoundException: File res/layout/...异常

今天快要下班的时候出现一个异常,让人崩溃的异常:

09-27 19:32:56.092 7258-7258/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                 Process: xiake.vscreenshot, PID: 7258
                                                 android.content.res.Resources$NotFoundException: File res/layout/contact_header.xml from xml type layout resource ID #0x7f040034
                                                     at android.content.res.Resources.loadXmlResourceParser(Resources.java:3226)
                                                     at android.content.res.Resources.loadXmlResourceParser(Resources.java:3181)
                                                     at android.content.res.Resources.getLayout(Resources.java:1349)
                                                     at android.view.LayoutInflater.inflate(LayoutInflater.java:421)
                                                     at xiake.vscreenshot.adapter.ContactAdapter.onCreateHeaderViewHolder(ContactAdapter.java:104)
                                                     at com.jiang.android.lib.adapter.expand.HeaderViewCache.getHeader(HeaderViewCache.java:31)
                                                     at com.jiang.android.lib.adapter.expand.StickyRecyclerHeadersDecoration.getHeaderView(StickyRecyclerHeadersDecoration.java:141)
                                                     at com.jiang.android.lib.adapter.expand.StickyRecyclerHeadersDecoration.getItemOffsets(StickyRecyclerHeadersDecoration.java:63)
                                                     at android.support.v7.widget.RecyclerView.getItemDecorInsetsForChild(RecyclerView.java:4609)
                                                     at android.support.v7.widget.RecyclerView$LayoutManager.measureChildWithMargins(RecyclerView.java:8669)
                                                     at android.support.v7.widget.LinearLayoutManager.layoutChunk(LinearLayoutManager.java:1568)
                                                     at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1502)
                                                     at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:595)
                                                     at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3625)
                                                     at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3354)
                                                     at android.support.v7.widget.RecyclerView.onLayout(RecyclerView.java:3886)
                                                     at android.view.View.layout(View.java:17050)
                                                     at android.view.ViewGroup.layout(ViewGroup.java:5579)
                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:396)
                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
                                                     at android.view.View.layout(View.java:17050)
                                                     at android.view.ViewGroup.layout(ViewGroup.java:5579)
                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:2001)
                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1844)
                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1753)
                                                     at android.view.View.layout(View.java:17050)
                                                     at android.view.ViewGroup.layout(ViewGroup.java:5579)
                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:396)
                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
                                                     at android.view.View.layout(View.java:17050)
                                                     at android.view.ViewGroup.layout(ViewGroup.java:5579)
                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:2001)
                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1844)
                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1753)
                                                     at android.view.View.layout(View.java:17050)
                                                     at android.view.ViewGroup.layout(ViewGroup.java:5579)
                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:396)
                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
                                                     at android.view.View.layout(View.java:17050)
                                                     at android.view.ViewGroup.layout(ViewGroup.java:5579)
                                                     at android.widget.LinearLayout.setChildFrame(LinearLayout.java:2001)
                                                     at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1844)
                                                     at android.widget.LinearLayout.onLayout(LinearLayout.java:1753)
                                                     at android.view.View.layout(View.java:17050)
                                                     at android.view.ViewGroup.layout(ViewGroup.java:5579)
                                                     at android.widget.FrameLayout.layoutChildren(FrameLayout.java:396)
                                                     at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
                                                     at com.android.internal.policy.PhoneWindow$DecorView.onLayout(PhoneWindow.java:2794)
                                                     at android.view.View.layout(View.java:17050)
                                                     at android.view.ViewGroup.layout(ViewGroup.java:5579)
                                                     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2573)
                                                     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2273)
                                                     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1340)
                                                     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6809)
                                                     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:894)
                                                    at android.view.Choreographer.do

意思很明确了 找不到这个资源文件
android.content.res.Resources$NotFoundException: File res/layout/

contact_header.xml

from xml type layout resource ID #0x7f040034

我在网上找了相关的解决方案,网上都是说检查这个文件看有没有写错,查了100遍,确定代码没有问题.
然后我像这个 #0x7f040034不就是R文件里面的东西吗,我就索性把R文件删除了,但是..还是有各种崩溃报找不到文件.

最后我仔细冷静了想了想,把项目和module的build文件夹全部删除,最后完美解决

如果这个方案解决了你的Bug请给我一个回复,谢谢啦!!!

你可能感兴趣的:(Android)