Android谷歌地图应用程序通过 Intent 从一个 Activity 调用崩溃

标签 android google-maps google-maps-android-api-2

我正在使用 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。

关注https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2

关于Android谷歌地图应用程序通过 Intent 从一个 Activity 调用崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21548231/

相关文章:

jquery - 使用Google Maps Javascript API v3的HTML/CSS标记

Android 谷歌地图在标记上长按/在标记上触摸带有运动事件

android - 缩小时聚类 map 标记,放大时取消聚类

android - 在不编译的情况下测试我的android库

javascript - 是否可以从照片中读取地理标记以在谷歌地图 API 中使用?

android - 糟糕的 ImageView 位图质量?

google-maps - 更改 UISearchBar textColor 不起作用

android - 我如何解决在 android fragment 中集成谷歌地图

android - 如何从相机android获取物体距离?

java - 我的 Android 天气应用程序出现奇怪的 "Only the original thread that created a view hierarchy can touch its views."错误