こんにちは、Google マップ v2 に問題があります。このリンクをたどっています https://developers.google.com/maps/documentation/android/start#installing_the_google_maps_android_v2_api しかし、次のようなエラー メッセージが表示されます
05-22 22:24:07.476: E/AndroidRuntime(19690): FATAL EXCEPTION: main
05-22 22:24:07.476: E/AndroidRuntime(19690): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.easytaxi/com.example.easytaxi.MainActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.os.Handler.dispatchMessage(Handler.java:99)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.os.Looper.loop(Looper.java:130)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.app.ActivityThread.main(ActivityThread.java:3687)
05-22 22:24:07.476: E/AndroidRuntime(19690): at java.lang.reflect.Method.invokeNative(Native Method)
05-22 22:24:07.476: E/AndroidRuntime(19690): at java.lang.reflect.Method.invoke(Method.java:507)
05-22 22:24:07.476: E/AndroidRuntime(19690): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
05-22 22:24:07.476: E/AndroidRuntime(19690): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
05-22 22:24:07.476: E/AndroidRuntime(19690): at dalvik.system.NativeStart.main(Native Method)
05-22 22:24:07.476: E/AndroidRuntime(19690): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-22 22:24:07.476: E/AndroidRuntime(19690): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.app.Activity.setContentView(Activity.java:1657)
05-22 22:24:07.476: E/AndroidRuntime(19690): at com.example.easytaxi.MainActivity.onCreate(MainActivity.java:12)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
05-22 22:24:07.476: E/AndroidRuntime(19690): ... 11 more
05-22 22:24:07.476: E/AndroidRuntime(19690): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/data/app/com.example.easytaxi-1.apk]
05-22 22:24:07.476: E/AndroidRuntime(19690): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
05-22 22:24:07.476: E/AndroidRuntime(19690): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
05-22 22:24:07.476: E/AndroidRuntime(19690): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
05-22 22:24:07.476: E/AndroidRuntime(19690): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
05-22 22:24:07.476: E/AndroidRuntime(19690): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
05-22 22:24:07.476: E/AndroidRuntime(19690): ... 19 more`enter code here`
これは私の MainActivity.java ファイルです
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@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 version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.easytaxi"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<permission
android:name="com.example.easytaxi.permission.MAPS_RECEIVE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.easytaxi.permission.MAPS_RECEIVE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!--
The following two permissions are not required to use
Google Maps Android API v2, but are recommended.
-->
<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.example.easytaxi.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="My API Key" />
</application>
</manifest>
これは私の activity_main.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"/>
また、エミュレータではなく携帯電話で実行しています。すでにGoogle Playサービスをインストールしているため、どこで間違いを犯しているのかわかりません。よろしくお願いします。