Android Google maps v2 error while inflating fragment

后端 未结 2 1754
夕颜
夕颜 2020-12-19 23:29

I am totally baffled with google map implementation for a day and half. i followed all necessary steps mention in ths link. https://developers.google.com/maps/documentati

相关标签:
2条回答
  • 2020-12-20 00:11

    Add

    <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="**Replace with your key**" />
    

    in the manifest

    This is the correct Android_manifest.xml for displaying maps

    <?xml version="1.0" encoding="utf-8"?>
    <uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="19" />
    
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <uses-library android:name="com.google.android.maps" />
        <activity
            android:name="com.example.package.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <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="**Replace with your key**" />
    </application>
    

    Dont forget to add google-play-services_lib

    0 讨论(0)
  • 2020-12-20 00:15

    Your logcat clearly said

    Caused by: java.lang.IllegalStateException: The meta- data tag in your app's AndroidManifest.xml does not have the right value. Expected 4323000 but found 0. You must have the following declaration within the element:

    Try to add Google play services version using <meta-data> tag under <application> tag in your manifest.xml file like

    <meta-data
    android:name="com.google.android.gms.version"
    android:value="@integer/google_play_services_version" />
    

    Make your manifest.xml like

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