Android - Failed to find provider info for com.google.settings in MapView Example

后端 未结 5 1929
面向向阳花
面向向阳花 2021-02-13 12:15

I\'m trying to implement the MapView example which is defined in Android Hello Views example but now I\'m facing this error:

Failed to find provider info for com         


        
相关标签:
5条回答
  • 2021-02-13 12:47

    If you've made sure you have INTERNET permission, and have correctly generated API key, and have put it in android:apiKey, and the same error still happens, here's one more thing to check: is your application signed with the same certificate that you used for Maps API key?

    Android build tools use different certificates for debug builds and for release builds. If you've generated MD5 checksum and API key for release certificate (the one that you use in "Export Android Application" wizard to generate .apk), it won't work in debug builds--and vice versa.

    You can find out where your debug keystore is located in Eclipse's Preferences > Android > Build page. You can generate MD5 checksum and API key for it the same way as for your release certificate. Default password for debug keystore is "android".

    Here's official docs about debug keystore

    0 讨论(0)
  • 2021-02-13 12:47

    One more thing to check:

    I just had this problem (or rather, my problem was that the map was not showing up). I had skimmed through the map view tutorial and pasted the "uses-permission" tag inside the application tag by mistake. It needs to be directly under the manifest tag, like this:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest [...]>
      <uses-sdk [...] />
      <uses-permission android:name="android.permission.INTERNET" />
    
      <application android:icon="@drawable/icon" android:label="@string/app_name">
        <uses-library android:name="com.google.android.maps" />
        [...]
      </application>
    </manifest>
    

    A very simple mistake, but it took me a while to find. Hopefully this helps someone else!

    0 讨论(0)
  • 2021-02-13 12:53

    I have only encountered this issue on the emulator and I have found that the only way around this error is to restart the emulator.

    0 讨论(0)
  • 2021-02-13 13:01

    The MapView example doesn't set API key by default. So you must set it. Here is step by step:

    1. Get MD5 from your system

      %JAVA_HOME%\bin\keytool.exe -list -alias androiddebugkey -keystore "%userprofile%\.android\debug.keystore" -storepass android -keypass android
      
    2. Get API key by pasting the generated MD5 to this page:
      http://code.google.com/android/maps-api-signup.html

    3. Paste the generated API key to {your_project_root}/res/layout/map.xml

      <com.google.android.maps.MapView
          android:id="@+id/myMapView"
          android:layout_width="fill_parent" 
          android:layout_height="fill_parent"
          android:enabled="true"
          android:clickable="true"
          android:apiKey="paste_generated_api_key_here"
      />
      
    4. In AndroidManifest.xml, make sure that you have the folowing tag into your application tag:

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

      and also the folowing tag into your manifest tag:

      <uses-permission android:name="android.permission.INTERNET" />
      
    5. Refresh your project and run

    Note:

    • The path of keytool.exe, debug.keystore and map.xml may differ on your system.
    • If you publish your app, be sure to register another API key.
    • If you don't set API key properly, your app will fail on phone and the error message probably is "... has stopped unexpectedly. Please try again. - Force close"

    More detail at http://d.android.com/guide/tutorials/views/hello-mapview.html

    0 讨论(0)
  • 2021-02-13 13:01

    Just review Hello, MapView :

    Make sure you have included into AndroidManifest.xml line for permissions:

    <uses-permission android:name="android.permission.INTERNET" />
    

    Also, have you got Google Map API Key?
    Put it into MapView layout definition:

    <com.google.android.maps.MapView
        android:id="@+id/mapview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:clickable="true"
        android:apiKey="Your Maps API Key"
    />
    

    Other mention of error: GGroups - MapView showing as black screen after upgrade to 1.5

    0 讨论(0)
提交回复
热议问题