遇到这种报错。
public int getLayoutDimension(int index, int defValue) {
if (mRecycled) {
throw new RuntimeException("Cannot make calls to a recycled instance!");
}
index *= AssetManager.STYLE_NUM_ENTRIES;
final int[] data = mData;
final int type = data[index+AssetManager.STYLE_TYPE];
if (type >= TypedValue.TYPE_FIRST_INT
&& type <= TypedValue.TYPE_LAST_INT) {
return data[index+AssetManager.STYLE_DATA];
} else if (type == TypedValue.TYPE_DIMENSION) {
return TypedValue.complexToDimensionPixelSize(
data[index+AssetManager.STYLE_DATA], mMetrics);
}
return defValue;
}
发现是只在某个分辨率定义了dimen值 默认value没有定义。在其他分辨率下无值导致了崩溃
本文介绍了一种在特定分辨率下未定义dimen值导致应用崩溃的问题及解决方案。通过对代码逻辑的理解,确定了在不同分辨率下dimen值缺失时的处理方式,避免了运行时错误。

被折叠的 条评论
为什么被折叠?



