Google Maps v2 Simple Application Not Working

前端 未结 3 440
抹茶落季
抹茶落季 2021-01-23 14:51

I am following this tutorial. Here are all my related files: activity_main.xml




        
相关标签:
3条回答
  • 2021-01-23 15:04

    You need do give External Storage permission with both meta-data:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
        <application
        <meta-data
                android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version" />
             <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="AIzaSyCm5xJy0AwN4TfXM6ccpfj2GhqZneFCyiM" />
         </application>
    
    0 讨论(0)
  • 2021-01-23 15:10

    You need to have two meta-data fields. One is required for google play services in general, the second one on top for using maps.

    Example snippet from the sample application you should have in [android-sdk]/extras/google/google_play_services/samples/maps/AndroidManifest.xml

      <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/demo_title"
        android:hardwareAccelerated="true">
        <!-- ** You need to replace the key below with your own key. **
             The example key below will not be accepted because it is not linked to the
             certificate which you will use to sign this application.
             See: https://developers.google.com/maps/documentation/android/start
             for instructions on how to get your own key. -->
    
        <meta-data
                android:name="com.google.android.maps.v2.API_KEY"
                android:value="AIzaSyCvGBr5in13NK2yYBR7lhXTtnxj3mrXQy4" />
    
        <meta-data
                android:name="com.google.android.gms.version"
                android:value="@integer/google_play_services_version" />
    
    0 讨论(0)
  • 2021-01-23 15:14

    you need

    <application..>
        <meta-data
             android:name="com.google.android.gms.version"
             android:value="@integer/google_play_services_version" />
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="KEY" />
    
        ...
    </application>
    
    0 讨论(0)
提交回复
热议问题