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

 找回密码
 注册
搜索

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

[复制链接]
发表于 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-6 13:26 , Processed in 0.051946 second(s), 11 queries , File On.

Powered by Discuz! X3.3

© 2001-2017 Comsenz Inc.

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