Android - 无法在MapView示例中查找com.google.settings的提供商信息

sar*_*mad 12 android android-mapview

我正在尝试实现在Android Hello Views示例中定义的MapView示例,但现在我遇到了这个错误:

Failed to find provider info for com.google.settings
Run Code Online (Sandbox Code Playgroud)

知道为什么会这样吗?

Coc*_* B. 14

默认情况下,MapView示例不会设置API密钥.所以你必须设置它.这是一步一步:

  1. 从您的系统获取MD5

    %JAVA_HOME%\bin\keytool.exe -list -alias androiddebugkey -keystore "%userprofile%\.android\debug.keystore" -storepass android -keypass android
    
    Run Code Online (Sandbox Code Playgroud)
  2. 通过将生成的MD5粘贴到此页面来获取API密钥:http:
    //code.google.com/android/maps-api-signup.html

  3. 将生成的API密钥粘贴到{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"
    />
    
    Run Code Online (Sandbox Code Playgroud)
  4. 在AndroidManifest.xml中,确保您的标记中包含以下application标记:

    <uses-library android:name="com.google.android.maps" />
    
    Run Code Online (Sandbox Code Playgroud)

    以及标记中的以下manifest标记:

    <uses-permission android:name="android.permission.INTERNET" />
    
    Run Code Online (Sandbox Code Playgroud)
  5. 刷新项目并运行

注意:

  • keytool.exe,debug.keystore和map.xml的路径可能因系统而异.
  • 如果您发布了应用程序,请务必注册其他API密钥.
  • 如果您没有正确设置API密钥,您的应用程序将在手机上失败并且错误消息可能是" ...已意外停止.请再试一次. - 强制关闭 "

有关详细信息,请访问http://d.android.com/guide/tutorials/views/hello-mapview.html


Mak*_*tar 0

只需回顾一下Hello,MapView:

确保您已将权限包含到 AndroidManifest.xml 行中:

<uses-permission android:name="android.permission.INTERNET" />
Run Code Online (Sandbox Code Playgroud)

另外,你有Google 地图 API 密钥吗?
将其放入MapView布局定义中:

<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"
/>
Run Code Online (Sandbox Code Playgroud)

其他提到的错误: GGroups - MapView 在升级到 1.5 后显示为黑屏