'Failed to find style mapViewStyle'错误仍然存在。
'Failed to find style mapViewStyle'错误仍然存在。
我已经花了将近一年的时间在这个应用上工作(毕业项目),然而几天前它突然出了问题。我的应用是使用Eclipse 3.7.2 64位版本开发的,目标是Froyo Android 2.2,我使用的是Windows 7 64位电脑。到目前为止,我尝试过以下方法:\n
- \n
- 重新调整清单文件中的uses-library标签
- 重写地图XML文件
- 删除R.java文件并刷新
- 将mapview元素放置在布局中
- 重新安装Eclipse和Android SDK
- 清理项目
- 创建style.xml文件并引用它
- 在实际设备上部署
- 恢复到之前的代码
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n可能还有其他尝试...\n我的代码如下:\ngmap.xml\n
\nAndroidManifest.xml\n
\n非常感谢提前提供的任何帮助。
('Failed to find style mapViewStyle' error persists)这个问题的出现的原因是com.google.android.maps.MapView已经过时了,现在应该使用com.google.android.gms.maps.MapView。解决方法是参考http://developer.android.com/reference/com/google/android/gms/maps/MapView.html,如果想使用MapFragment,则可以查看http://www.androidhive.info/2013/08/android-working-with-google-maps-v2/。
在使用Google地图服务时,可能会遇到"Failed to find style mapViewStyle"错误。出现这个问题的原因是没有正确引入Google Play服务库,并且没有添加必要的权限。
解决方法如下:
1. 在项目中添加外部库。将以下路径中的库添加为项目的外部库:/path_to_android-sdk/extras/google/google_play_services/libproject/google-play-services_lib
。这可以通过在项目的build.gradle文件中添加以下代码来实现:
dependencies { implementation project(':google-play-services_lib') }
2. 添加Google Play服务库中的jar文件。将以下路径中的jar文件添加到项目中:/path_to_android-sdk/extras/google/google_play_services/libproject/google-play-services_lib/libs/google-play-services.jar
。可以通过在项目的build.gradle文件中添加以下代码来实现:
dependencies { implementation files('path_to_jar_file/google-play-services.jar') }
3. 添加必要的权限。在AndroidManifest.xml文件中添加以下权限:
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
确保以上代码在<manifest>标签内部。
通过以上步骤,您应该能够解决"Failed to find style mapViewStyle"错误,并且能够正常使用Google地图服务。