android - 为什么应用程序仅在我应用更改时因为缺少维度(对于谷歌地图)而崩溃?
问题描述
我的应用程序仅在我应用更改时(而不是在我运行应用程序时)崩溃,并且在我加载谷歌地图的片段中失败。给出的错误如下:
Process: com.locatecars.findspot, PID: 20722
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.locatecars.findspot/com.locatecars.findspot.MainActivity}: android.content.res.Resources$NotFoundException: Resource "com.locatecars.findspot:dimen/card_icon_multiline_padding_bottom" (7f060059) is not a Drawable (color or path): TypedValue{t=0x5/d=0xc30c21 a=3 r=0x7f060059}
这个错误指向我的方法是:
private void initGoogleMap(Bundle savedInstanceState) {
Bundle mapViewBundle = null;
if (savedInstanceState != null) {
mapViewBundle = savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY);
}
mapView.onCreate(mapViewBundle); //<-- this line in particular
mapView.getMapAsync(this);
if (geoApiContext == null) {
geoApiContext = new GeoApiContext.Builder().apiKey(getString(R.string.google_api_key)).build();
}
}
编辑 这是克里斯建议后的片段
Bundle mapViewBundle = savedInstanceState != null ?
savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY) : new Bundle();
savedInstanceState.putBundle(MAPVIEW_BUNDLE_KEY, mapViewBundle);
mapView.onSaveInstanceState(mapViewBundle);
编辑 2
在再次考虑了克里斯的回答之后,这就是有效的:
Bundle mapViewBundle = savedInstanceState != null ?
savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY) : new Bundle();
mapView.onSaveInstanceState(mapViewBundle);
解决方案
看起来您正在传递一个空包。尝试这样的事情:
Bundle mapViewBundle = savedInstanceState != null ?
savedInstanceState.getBundle(MAPVIEW_BUNDLE_KEY) : new Bundle();
推荐阅读
- c++ - 模板函数参数显式类型声明
- java - Eclipse 没有正确显示项目资源管理器
- sql - 寻找平均每日价值
- angular - Typescript - 从字符串中提取值
- java - Spring webapp显示来自数据库的动态内容
- python - tf.data.dataset.shuffle 的机制是什么?
- google-cloud-platform - SpannerIO 批量读取速度受慢分区读取器影响
- python - Python在dict_keys中查找dict和嵌套值并交换值
- r - 当 X > 1 时如何关联 2 个变量
- java - Google 联系 gdata (Java) 在没有内容类型解析器时失败:application-xml [application/xml]