Android的 - 谷歌地图API第2版 - SupportMapFragment错误 [英] Android - Google Maps API v2 - SupportMapFragment Errors

查看:248
本文介绍了Android的 - 谷歌地图API第2版 - SupportMapFragment错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的应用程序之一备份,并与谷歌地图API第2,第一次运行。我在我的密钥库中创建一个键我的应用程序,提取的SHA1哈希值,获得API密钥,然后做下面的在应用程序...我包括:

I am trying to get one of my apps back up and running with the Google Maps API v2 for the first time. I created a key for my app in my keystore, extracted the SHA1 hash, acquired an API key, then did the following in-app... I included:

谷歌播放services.jar

google-play-services.jar

以及导入GooglePlayServices libraryand增加它作为参考到项目。在我的Java code我只是简单地加载布局资源。

as well as importing the GooglePlayServices libraryand adding it as a reference to the project. In my Java code I simply just load the layout resource.

public class Times extends Activity{
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.map);
    }
}

在布局(RES /设计/ map.xml),我试图实例我有:

In the layout (res/layout/map.xml) that I am trying to instantiate I have:

<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

我也有以下的在我的清单中声明:

I also have the following declared in my manifest:

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="tinyTech.us.ua.busschedule.permission.MAPS_RECEIVE" />

<permission
    android:name="tinyTech.us.ua.busschedule.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

和清单中的应用程序标记中声明:

And declared in the Application tag of the manifest:

<meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="My_API_Key" />

在活动被加载时,它在LogCat中出现以下错误崩溃了:

When the activity is loaded, it crashes with the following errors in LogCat:

FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
    at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)

我试图研究这个问题,但我一直无法找到我所期待的。任何及所有的帮助是很大的AP preciated。

I have attempted to research the problem, however I have been unable to find what I am looking for. Any and all help is greatly appreciated.

推荐答案

您需要,如果你使用的是SupportMapFragment扩展FragmentActivity。 如果您使用的是MapFragment可以延长活动。

You need to extend FragmentActivity if you are using SupportMapFragment. If you are using the MapFragment you can extend Activity.

这篇关于Android的 - 谷歌地图API第2版 - SupportMapFragment错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆