Android SupportMapFragment Exception Error

核能气质少年 提交于 2019-11-29 04:55:34
Sloy

In onCreateView() you must call its parent. Check my solution in https://stackoverflow.com/a/13734470/835787 closer. The map is initialized in the onCreateView() method of MapFragment, if you don't call it the map will be null.

  1. super.onCreate(savedInstanceState); should be called in onCreate(), not onCreateView()
  2. If you want to override onCreateView(), it should be something like:

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = super.onCreateView(inflater, container, savedInstanceState);
    
        // Do any other initialization you need, but note that the MapView already exists inside v
    
        setUpMapIfNeeded(v);
        return v;
    }
    

I don't know is it helps or not but you should set your package here:

    <permission
    android:name="com.example.newmapview.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.newmapview.permission.MAPS_RECEIVE" />

I solved this error by checking "Copy projects into workspace" while importing the Google Play Services lib.
More info here: http://developer.android.com/google/play-services/setup.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!