Googleマップを実装しようとしています。しかし、それは常にエラーになります。
マイ アクティビティ
package com.alex.googlemaps;
import android.os.Build;
import android.os.Bundle;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import android.annotation.TargetApi;
import android.app.Activity;
import android.view.Menu;
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public class MainActivity extends Activity {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
mMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
final LatLng CIU = new LatLng(35.21843892856462, 33.41662287712097);
Marker ciu = mMap.addMarker(new MarkerOptions()
.position(CIU).title("My Office"));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
私のXMLファイル
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.MapFragment" />
</RelativeLayout>
マニフェスト ファイル
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.alex.googlemaps"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<permission
android:name="com.example.androidmapsv2.permission.MAPS_RECEIVE"
android:protectionLevel="signature" >
</permission>
<uses-permission android:name="com.alex.googlemaps.permission.MAPS_RECEIVE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.alex.googlemaps.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyD-zPbxq6kH0cjw-Axfey-WZ3cmlXqf2LE" />
</application>
</manifest>
そしてlogCatは次のように表示されます
04-05 05:44:02.598: E/Trace(1057): error opening trace file: No such file or directory (2)
04-05 05:44:03.038: W/GooglePlayServicesUtil(1057): Google Play services out of date. Requires 3025100 but found 2012110
04-05 05:44:03.058: W/GooglePlayServicesUtil(1057): Google Play services out of date. Requires 3025100 but found 2012110
04-05 05:44:03.148: W/GooglePlayServicesUtil(1057): Google Play services out of date. Requires 3025100 but found 2012110
04-05 05:44:03.188: W/GooglePlayServicesUtil(1057): Google Play services out of date. Requires 3025100 but found 2012110
04-05 05:44:03.198: W/GooglePlayServicesUtil(1057): Google Play services out of date. Requires 3025100 but found 2012110
04-05 05:44:03.258: W/GooglePlayServicesUtil(1057): Google Play services out of date. Requires 3025100 but found 2012110
04-05 05:44:03.258: D/AndroidRuntime(1057): Shutting down VM
04-05 05:44:03.268: W/dalvikvm(1057): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
04-05 05:44:03.278: E/AndroidRuntime(1057): FATAL EXCEPTION: main
04-05 05:44:03.278: E/AndroidRuntime(1057): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.alex.googlemaps/com.alex.googlemaps.MainActivity}: java.lang.NullPointerException
04-05 05:44:03.278: E/AndroidRuntime(1057): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-05 05:44:03.278: E/AndroidRuntime(1057): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-05 05:44:03.278: E/AndroidRuntime(1057): at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-05 05:44:03.278: E/AndroidRuntime(1057): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-05 05:44:03.278: E/AndroidRuntime(1057): at android.os.Handler.dispatchMessage(Handler.java:99)
04-05 05:44:03.278: E/AndroidRuntime(1057): at android.os.Looper.loop(Looper.java:137)
04-05 05:44:03.278: E/AndroidRuntime(1057): at android.app.ActivityThread.main(ActivityThread.java:5041)
04-05 05:44:03.278: E/AndroidRuntime(1057): at java.lang.reflect.Method.invokeNative(Native Method)
04-05 05:44:03.278: E/AndroidRuntime(1057): at java.lang.reflect.Method.invoke(Method.java:511)
04-05 05:44:03.278: E/AndroidRuntime(1057): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-05 05:44:03.278: E/AndroidRuntime(1057): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-05 05:44:03.278: E/AndroidRuntime(1057): at dalvik.system.NativeStart.main(Native Method)
04-05 05:44:03.278: E/AndroidRuntime(1057): Caused by: java.lang.NullPointerException
04-05 05:44:03.278: E/AndroidRuntime(1057): at com.alex.googlemaps.MainActivity.onCreate(MainActivity.java:24)
04-05 05:44:03.278: E/AndroidRuntime(1057): at android.app.Activity.performCreate(Activity.java:5104)
04-05 05:44:03.278: E/AndroidRuntime(1057): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-05 05:44:03.278: E/AndroidRuntime(1057): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-05 05:44:03.278: E/AndroidRuntime(1057): ... 11 more
04-05 05:44:03.378: D/dalvikvm(1057): GC_CONCURRENT freed 257K, 14% free 2545K/2948K, paused 16ms+3ms, total 114ms
04-05 05:44:06.338: I/Process(1057): Sending signal. PID: 1057 SIG: 9
私はたくさんグーグルで検索しましたが、すべての結果がついにエラーを出しています。誰でもこの問題を解決するのを手伝ってください。