Android - 无法在 MapView 示例中找到 com.google.settings 的提供商信息
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1988078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android - Failed to find provider info for com.google.settings in MapView Example
提问by sarmad
I'm trying to implement the MapView example which is defined in Android Hello Views example but now I'm facing this error:
我正在尝试实现在 Android Hello Views 示例中定义的 MapView 示例,但现在我遇到了这个错误:
Failed to find provider info for com.google.settings
Any idea why this is happening?
知道为什么会这样吗?
回答by Coc B.
The MapView example doesn't set API key by default. So you must set it. Here is step by step:
MapView 示例默认不设置 API 密钥。所以你必须设置它。这是一步一步:
Get MD5 from your system
%JAVA_HOME%\bin\keytool.exe -list -alias androiddebugkey -keystore "%userprofile%\.android\debug.keystore" -storepass android -keypass android
Get API key by pasting the generated MD5 to this page:
http://code.google.com/android/maps-api-signup.htmlPaste 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" />
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" />
Refresh your project and run
从您的系统中获取 MD5
%JAVA_HOME%\bin\keytool.exe -list -alias androiddebugkey -keystore "%userprofile%\.android\debug.keystore" -storepass android -keypass android
通过将生成的 MD5 粘贴到此页面来获取 API 密钥:http:
//code.google.com/android/maps-api-signup.html将生成的 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" />
在AndroidManifest.xml 中,确保您的标签中有以下
application
标签:<uses-library android:name="com.google.android.maps" />
以及以下标签到您的
manifest
标签中:<uses-permission android:name="android.permission.INTERNET" />
刷新您的项目并运行
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"
- keytool.exe、debug.keystore 和 map.xml 的路径可能因您的系统而异。
- 如果您发布应用程序,请务必注册另一个 API 密钥。
- 如果您没有正确设置 API 密钥,您的应用程序将在手机上失败,并且错误消息可能是“ ...已意外停止。请重试。-强制关闭”
More detail at http://d.android.com/guide/tutorials/views/hello-mapview.html
更多详情见 http://d.android.com/guide/tutorials/views/hello-mapview.html
回答by Pēteris Caune
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?
如果您已确定您拥有INTERNET
权限,并正确生成了 API 密钥并将其放入 中android:apiKey
,但仍然发生同样的错误,那么还有一件事需要检查:您的应用程序是否使用与地图相同的证书进行签名API 密钥?
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.
Android 构建工具使用不同的证书进行调试构建和发布构建。如果您为发布证书生成了 MD5 校验和和 API 密钥(您在“导出 Android 应用程序”向导中用于生成 .apk 的那个),它在调试版本中将不起作用,反之亦然。
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".
您可以在 Eclipse 的 Preferences > Android > Build 页面中找到调试密钥库的位置。您可以按照与发布证书相同的方式为其生成 MD5 校验和和 API 密钥。调试密钥库的默认密码是“android”。
回答by Rolf Staflin
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:
我刚刚遇到了这个问题(或者更确切地说,我的问题是地图没有显示出来)。我浏览了地图视图教程并错误地将“uses-permission”标签粘贴到了应用程序标签中。它需要直接在 manifest 标签下,像这样:
<?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!
一个非常简单的错误,但我花了一段时间才找到。希望这对其他人有帮助!
回答by Roy Hinkley
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.
我只在模拟器上遇到过这个问题,我发现解决这个错误的唯一方法是重新启动模拟器。
回答by Maksym Gontar
Just review Hello, MapView :
只是回顾你好, MapView:
Make sure you have included into AndroidManifest.xml line for permissions:
确保您已将权限包含在 AndroidManifest.xml 行中:
<uses-permission android:name="android.permission.INTERNET" />
Also, have you got Google Map API Key?
Put it into MapView layout definition:
另外,你有Google Map API Key吗?
将其放入 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"
/>
Other mention of error: GGroups - MapView showing as black screen after upgrade to 1.5
其他提到的错误: GGroups - MapView 在升级到 1.5 后显示为黑屏