大马资讯论坛 - 马来西亚中文资讯平台

 找回密码
 注册
搜索
打印 上一主题 下一主题

[教学] Android MapFragment.getMap()' on a null object reference

[复制链接]
跳转到指定楼层
1#
发表于 2015-7-17 20:47:20 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.android.gms.maps.GoogleMap com.google.android.gms.maps.MapFragment.getMap()' on a null object reference

ClassLoader.loadClass: The class loader returned by Thread.getContextClassLoader() may fail for processes that host multiple applications. You should explicitly specify a context class loader. For example: Thread.setContextClassLoader(getClass().getClassLoader());

Solution 解决方案

  1. MapFragment mapFragment = (MapFragment) getChildFragmentManager().findFragmentById(R.id.mapView);

  2. if(mapFragment == null){
  3.     return;
  4. }

  5. googleMap = mapFragment.getMap();
复制代码

手机版|大马资讯论坛  

GMT+8, 2024-12-1 14:40 , Processed in 0.022335 second(s), 11 queries , File On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表