Error Inflating class com.google.android.maps.MapView

前端 未结 9 919
遇见更好的自我
遇见更好的自我 2020-11-30 13:45

i am just following a simple map tutorial http://developer.android.com/resources/tutorials/views/hello-mapview.html but getting this error . I am new to android i tried to f

相关标签:
9条回答
  • 2020-11-30 14:08

    The emulator on which you are running the application does not have google map jar. so create emulator from Google API run your application there.

    See the image to create emulator with Google API

    enter image description here

    0 讨论(0)
  • 2020-11-30 14:15

    I had the problem. Just extend MapActivity instead of Activity.

    0 讨论(0)
  • 2020-11-30 14:16

    Did you extend the main class as MapActivity?

    public class a extends MapActivity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        }
    
        @Override
        protected boolean isRouteDisplayed() {
            // TODO Auto-generated method stub
            return false;
        }
    }
    
    0 讨论(0)
  • 2020-11-30 14:18

    One gets this exception even if all the steps mentioned above are followed but api-key is not specified for the MapView. Just add the api-key which you got from google

    <com.google.android.maps.MapView
            android:id="@+id/mapview"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:clickable="true" 
             android:apiKey = "api-key_goes_here"
      >
    
    0 讨论(0)
  • 2020-11-30 14:20

    I had this problem and solved it by the following 2 steps:

    1) Put the following line in the application (important) element of AndroidManifest.xml file.

    <uses-library android:name="com.google.android.maps" />
    

    2) extend MapActivity instead of Activity.

    enjoy!

    0 讨论(0)
  • 2020-11-30 14:25

    I know the following wasn't the error of the original questioner - but since my problem led to the same error message, I thought I might as well add it in case someone in the future runs into it.

    I checked all the other good hints, but none of them were missing in my project.

    What finally solved the problem for me, was that I forgot to declar the MapView in the layout including the full package name. Neither Eclipse nor Lint did tell me about this:

    <com.google.android.maps.MapView
        ...
        />
    
    0 讨论(0)
提交回复
热议问题