Java 尝试在Android上使用谷歌地图时出现异常
我正在尝试使用谷歌地图。所以我得到了Android API密钥: 我还打开了Google maps API V2: 在我的Java 尝试在Android上使用谷歌地图时出现异常,java,android,google-maps,Java,Android,Google Maps,我正在尝试使用谷歌地图。所以我得到了Android API密钥: 我还打开了Google maps API V2: 在我的AndroidManifest.xml中,我添加了: <meta-data android:name="com.google.android.maps.v2.API_KEY" android:value="AIzaSyAJR******************B2ur31EYL84"/>
AndroidManifest.xml
中,我添加了:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyAJR******************B2ur31EYL84"/>
在布局中,我添加了地图视图:
<com.google.android.gms.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1.0"
android:apiKey="AIzaSyAJR******************B2ur31EYL84"
android:clickable="true"
android:state_enabled="true" >
</com.google.android.gms.maps.MapView>
还有一个:
<com.google.android.gms.maps.MapView
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:apiKey="AIzaSyAJR******************B2ur31EYL84"
android:clickable="true" />
AndroidManifest以以下内容开头:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bssys"
android:versionCode="1"
android:versionName="1.1.1" >
我的程序包几乎都以com.bssys.android开头。/**类名或包**/
当我的活动开始时,我有一个例外:
堆栈跟踪太大。所以我把它写在单独的文件中 如何运行程序: 我在Intellij Idea上编写它,并在调试模式下运行。 使用Android SDK版本4.4。
在google nexus 7(Android 4.4)上运行您对google Maps V2使用了错误的视图类
com.google.android.maps.MapView
是旧的V1类
应该是
com.google.android.gms.maps.MapView
看看:
看起来您也没有为V2的清单文件设置正确的元数据
您可能只想查看Maps V1和V2之间发生的所有更改,因为它需要对代码进行一些返工,而不仅仅是一个简单的插入。好吧,当我使用它时,我没有将apikey放在布局中。我不知道这是否是错误的一部分。 不管怎样,你的权限设置正确了吗?我记得用过这些:
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<permission android:name="com.bssys.permission.MAPS_RECEIVE" android:protectionLevel="signature"></permission>
<uses-permission android:name="com.bssys.permission.MAPS_RECEIVE"/>
<uses-feature android:required="true" android:glEsVersion="0x00020000"/>
如果您使用的是不再受支持的旧谷歌地图,您需要使用Google play services@Balconsky查看谷歌地图v2-我会杀死/删除设备上的应用程序并尝试重新运行-编辑:删除了指向其他问题的链接-@Balconsky-我还会检查设备是否有有效的互联网连接[你可能有,但只是确保]是的,我确实没有互联网连接。这是因为我使用vpn连接到计算机。我需要两个连接,以便正确的程序工作。是的。但仍有例外。@Balconsky用更正更新您的问题,并描述您的测试方式(设备/操作系统/谷歌播放版本)