我正在使用 Google MapView Tutorial .我通过单击按钮调用此 map Activity ,但出现致命异常,请帮助我
这是我的 Activity 类:
public class AddLocationMap extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.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:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.google.android.gms.maps.MapFragment"/>
Logcat:这是 LogCat 输出
02-04 17:06:18.448: E/AndroidRuntime(2718): FATAL EXCEPTION: main
02-04 17:06:18.448: E/AndroidRuntime(2718): java.lang.NoClassDefFoundError: com.google.android.gms.R$styleable
02-04 17:06:18.448: E/AndroidRuntime(2718): at com.google.android.gms.maps.GoogleMapOptions.createFromAttributes(Unknown Source)
02-04 17:06:18.448: E/AndroidRuntime(2718): at com.google.android.gms.maps.MapFragment.onInflate(Unknown Source)
最佳答案
从您提供的链接 Google Maps Android v1 API(已弃用)
引用
Note: Version 1 of the Google Maps Android API has been officially deprecated as of December 3rd, 2012. This means that from March 18th, 2013 you will no longer be able to request an API key for this version. No new features will be added to Google Maps Android API v1. However, apps using v1 will continue to work on devices. Existing and new developers are encouraged to use Google Maps Android API v2.
切换到 API v2。
关于Android谷歌地图应用程序通过 Intent 从一个 Activity 调用崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21548231/