Android google map

后端 未结 4 977
陌清茗
陌清茗 2020-12-06 23:53

I am try to add Google MAP Api v2 in my application.but I am getting exception. Exception is

 java.lang.RuntimeException: Unable to start activity Component         


        
4条回答
  •  难免孤独
    2020-12-07 00:28

    You should use SupportMapFragment instead of MapFragment.

    Change

    
    

    to

    
    

    Also change

       _googleMap=((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
    

    to

    _googleMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(
            R.id.map)).getMap(); 
    

    And also If you're using fragments on older devices (pre Honeycomb) you should always extend your Activity from FragmentActivity.

    and also check

    Add the Google Play services version to your app's manifest

    Edit your application's AndroidManifest.xml file, and add the following declaration within the element. This embeds the version of Google Play services that the app was compiled with.

    You just need to add under tag into your AndroidManifest.xml

    ....
    
    
    

    This is because latest google play services requires a version name, which is to be mentioned using inside AndroidManifest.xml

提交回复
热议问题