【发布时间】:2013-07-18 13:20:57
【问题描述】:
我是 Android 新手,我正在尝试开发一个包含 Google 地图的 Android 应用程序。在我决定将 Google Play 服务从修订版 7 更新到 9 之前,该应用在模拟器上运行良好。
我现在遇到了与之前遇到的相同的错误(“Google Play 服务已过期...”),以及“致命异常:主要”错误。这是我在 logcat 中得到的:
http://imageshack.us/a/img11/8117/y1mq.png
如果我正确读取了 logcat,则错误在 MapTabActivity 中,但我不知道错误是由 Google Play 服务过期还是其他原因引起的......
在更新 Google Play 服务之前,该应用在模拟器上运行
- Nexus 4 设备
- Android 4.2.2(API 17 级)
- ARM CPU
- 已选择主机 GPU
我还必须安装其他帖子中推荐的 com.android.vending.apk 和 com.google.android.gms.apk。
我还为清单添加了必要的权限,并申请了一个 API 密钥,该密钥也包含在清单中。
谁能帮帮我?这是 MapTabActivity 及其对应的 XML。
MapTabActivity.java
package com.dissertation.closethedoordiss;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
public class MapTabActivity extends FragmentActivity {
private GoogleMap mMap;
private static final LatLng BRISTOL = new LatLng(51.455083,-2.586903);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maptab);
mMap = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mapView)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(BRISTOL, 13));
}
public void onClick_addretailer (View view) {
startActivity(new Intent("com.closethedoordiss.AddRetailerActivity"));
}
}
activity_maptab.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:name="com.google.android.gms.maps.SupportMapFragment"
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@android:drawable/ic_menu_add"
android:onClick="onClick_addretailer"
android:contentDescription="@string/add_button" />
</RelativeLayout>
提前感谢您提供的任何帮助。
【问题讨论】:
-
您确定安装的软件包(自动售货机、gms)是最新的吗?这看起来像是播放服务上可能的 uer-recoverable 错误,请参阅 developer.android.com/reference/com/google/android/gms/common/…
-
我最初使用这里提到的包link。我还尝试安装我认为是更新的软件包,但我不知道它们是否...问题仍然存在。
-
找出所需的版本(针对您的代码链接的版本)并尝试查看 android SDK 的目录(可能在 extras/google play services 中的某个地方)
-
如果我从 MapTabActivity.java 中删除
mMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(BRISTOL, 13));,应用程序会运行,但我会在模拟器 link 上得到它。
标签: java android google-maps android-emulator