我正在尝试第一次使用Google Maps API v2使我的应用恢复正常运行。 我在密钥库中为我的应用创建了一个密钥,提取了SHA1哈希值,获取了API密钥,然后在应用程序中执行以下操作...我包含了:
google-play-services.jar
同时导入GooglePlayServices库并将其添加为项目的引用。 在我的Java代码中,我只需加载布局资源。
public class Times extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
}
}
在我想要实例化的布局(res/layout/map.xml)中,我有以下内容:<?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" />
我在清单文件中也声明了以下内容:
<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" />
并在清单文件的Application标签中声明:
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="My_API_Key" />
当活动加载时,它会在LogCat中崩溃并显示以下错误:
FATAL EXCEPTION: main
java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
我尝试研究了这个问题,但是我无法找到我所需要的。非常感谢任何帮助。