Android開発は初めてです。Google Map APIの使用方法を示すこのリンクからプログラムを実行しようとしていました
ただし、手順に従って、HTC タブレットでアプリケーションを起動しようとした後。タブレットで「アプリケーションが予期せず停止しました」というエラーが表示されます。以下に示すように、logcat の出力をキャプチャしました。誰かがこの問題で私を助けてくれれば、本当に感謝しています。
01-11 20:30:43.703: D/dalvikvm(14541): GC_CONCURRENT freed 245K, 48% free 2975K/5639K, external 0K/0K, paused 3ms+9ms 01-11 20:30:43.884: D/dalvikvm(14541): GC_CONCURRENT freed 542K, 50% free 2987K/5959K, external 0K/0K, paused 3ms+4ms 01-11 20:30:43.924: D/AndroidRuntime(14541): Shutting down VM 01-11 20:30:43.924: W/dalvikvm(14541): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0) 01-11 20:30:43.924: E/AndroidRuntime(14541): FATAL EXCEPTION: main 01-11 20:30:43.924: E/AndroidRuntime(14541): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.googlemap/com.example.googlemap.MainActivity}: android.view.InflateException: Binary XML file line #15: Error inflating class fragment 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1840) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1861) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.app.ActivityThread.access$1500(ActivityThread.java:132) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.os.Handler.dispatchMessage(Handler.java:99) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.os.Looper.loop(Looper.java:150) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.app.ActivityThread.main(ActivityThread.java:4310) 01-11 20:30:43.924: E/AndroidRuntime(14541): at java.lang.reflect.Method.invokeNative(Native Method) 01-11 20:30:43.924: E/AndroidRuntime(14541): at java.lang.reflect.Method.invoke(Method.java:507) 01-11 20:30:43.924: E/AndroidRuntime(14541): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 01-11 20:30:43.924: E/AndroidRuntime(14541): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 01-11 20:30:43.924: E/AndroidRuntime(14541): at dalvik.system.NativeStart.main(Native Method) 01-11 20:30:43.924: E/AndroidRuntime(14541): Caused by: android.view.InflateException: Binary XML file line #15: Error inflating class fragment 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.view.LayoutInflater.inflate(LayoutInflater.java:408) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.view.LayoutInflater.inflate(LayoutInflater.java:320) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.view.LayoutInflater.inflate(LayoutInflater.java:276) 01-11 20:30:43.924: E/AndroidRuntime(14541): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:255) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.app.Activity.setContentView(Activity.java:1728) 01-11 20:30:43.924: E/AndroidRuntime(14541): at com.example.googlemap.MainActivity.onCreate(MainActivity.java:16) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1804) 01-11 20:30:43.924: E/AndroidRuntime(14541): ... 11 more 01-11 20:30:43.924: E/AndroidRuntime(14541): Caused by: java.lang.ClassNotFoundException: android.view.fragment in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.example.googlemap-2.apk] 01-11 20:30:43.924: E/AndroidRuntime(14541): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240) 01-11 20:30:43.924: E/AndroidRuntime(14541): at java.lang.ClassLoader.loadClass(ClassLoader.java:551) 01-11 20:30:43.924: E/AndroidRuntime(14541): at java.lang.ClassLoader.loadClass(ClassLoader.java:511) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.view.LayoutInflater.createView(LayoutInflater.java:471) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549) 01-11 20:30:43.924: E/AndroidRuntime(14541): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66) 01-11 20:30:43.924: E/AndroidRuntime(14541): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568) 01-11 20:30:43.924: E/AndroidRuntime(14541): ... 20 more
Manifest.xml は次のとおりです。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.googlemap"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<uses-library android:name="com.google.android.maps" />
<activity
android:name="MainActivity"
android:label="@string/title_activity_main" >
<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="AIzaSyBjpVaza7xnJkK64dlFl0v0n3h9QowvcB0"/>
</application>
<permission
android:name="com.example.googlemap.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.googlemap.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true"/>
</manifest>
MainActivity.xml は次のとおりです。
package com.example.googlemap;
import android.os.Bundle;
//import android.app.Activity;
import android.view.Menu;
//import android.view.MenuItem;
//import android.support.v4.app.NavUtils;
import com.google.android.maps.MapActivity;
//import com.google.android.maps.MapView;
public class MainActivity extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}
そして最後の activity_main.xml:
package com.example.googlemap;
import android.os.Bundle;
//import android.app.Activity;
import android.view.Menu;
//import android.view.MenuItem;
//import android.support.v4.app.NavUtils;
import com.google.android.maps.MapActivity;
//import com.google.android.maps.MapView;
public class MainActivity extends MapActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
@Override
protected boolean isRouteDisplayed() {
return false;
}
}