我是Android新手,我正在嘗試開發包含Google地圖的Android應用程序。該應用在仿真器上運行良好,直到我決定將Google Play服務從修訂版本7更新到9爲止。模擬器上的「致命異常:主要」和「Google Play服務過期」
我現在遇到了之前遇到的相同錯誤(「Google Play服務已過期...」) ,加上「致命異常:主要」錯誤。以下是我在logcat中得到:
http://imageshack.us/a/img11/8117/y1mq.png
如果我讀的logcat正確,錯誤是在MapTabActivity但我不知道,如果錯誤是由谷歌遊戲服務被淘汰所致日期,或如果是別的東西......
更新谷歌遊戲服務之前,應用程序正在模擬器上與
- 的Nexus 4設備
- 的Android 4.2.2(API LVL 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)嗎?這看起來像是播放服務中的一個可能的可恢復錯誤,請參閱http://developer.android.com/reference/com/google/android/gms/common/GooglePlayServicesUtil.html#isGooglePlayServicesAvailable(android.content.Context) –
我最初使用這裏提到的包[鏈接](http://stackoverflow.com/questions/14040185/running-google-maps-v2-on-android-emulator/17036337#17036337)。我也嘗試安裝,我認爲是更新的包,但我不知道他們是否......這個問題仍然存在。 – PierreM
找出需要哪個版本(與您的代碼鏈接到哪個版本),並嘗試查看Android SDK的目錄(可能在某些地方的額外/谷歌播放服務) –