java.lang.RuntimeException: Could not find layout layout/home_layout
at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:92)
at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:82)
at com.xtremelabs.robolectric.res.ViewLoader.inflateView(ViewLoader.java:86)
有人知道为什么会出现这个错误吗?根据我所看到的,robolectric版本1.1在加载布局文件的方式上没有改变,它会搜索layout/文件夹:
private ViewNode getViewNodeByLayoutName(String layoutName) {
if (layoutName.startsWith("layout/") && !qualifierSearchPath.isEmpty()) {
String rawLayoutName = layoutName.substring("layout/".length());
for (String location : qualifierSearchPath) {
ViewNode foundNode = viewNodesByLayoutName.get("layout-" + location + "/" + rawLayoutName);
if (foundNode != null) {
return foundNode;
}
}
}
return viewNodesByLayoutName.get(layoutName);
}
如果布局文件在另一个目录中(例如layout-normal-hdpi),则会出现此错误..
有没有人知道解决办法?