mapView に問題があります。これはコードです:
Android マニフェスト:
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<uses-library android:name="com.google.android.maps"/>
<activity
android:label="@string/app_name"
android:name=".TestjmkapActivity" >
<intent-filter >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
アクティビティ:
package test.pl.pl;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class TestjmkapActivity extends MapActivity {
MapView mapView;
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView)findViewById(R.id.map);
mapView.setBuiltInZoomControls(true);
mapView.setTraffic(false);
mapView.setSatellite(true);
mapView.setStreetView(true);
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
レイアウト:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.maps.MapView
android:id="@+id/map"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="100dp"
android:layout_width="100dp"
android:enabled="true"
android:clickable="true"
android:apiKey="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
/>
</LinearLayout>
これは、起動しようとしたときにlogcatに表示されたものです。
05-06 11:27:23.043: E/AndroidRuntime(565): FATAL EXCEPTION: main
05-06 11:27:23.043: E/AndroidRuntime(565): java.lang.RuntimeException: Unable to start activity ComponentInfo{test.pl.pl/test.pl.pl.TestjmkapActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class com.google.maps.MapView
05-06 11:27:23.043: E/AndroidRuntime(565): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.os.Handler.dispatchMessage(Handler.java:99)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.os.Looper.loop(Looper.java:123)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.app.ActivityThread.main(ActivityThread.java:4627)
05-06 11:27:23.043: E/AndroidRuntime(565): at java.lang.reflect.Method.invokeNative(Native Method)
05-06 11:27:23.043: E/AndroidRuntime(565): at java.lang.reflect.Method.invoke(Method.java:521)
05-06 11:27:23.043: E/AndroidRuntime(565): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-06 11:27:23.043: E/AndroidRuntime(565): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-06 11:27:23.043: E/AndroidRuntime(565): at dalvik.system.NativeStart.main(Native Method)
05-06 11:27:23.043: E/AndroidRuntime(565): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.google.maps.MapView
05-06 11:27:23.043: E/AndroidRuntime(565): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
05-06 11:27:23.043: E/AndroidRuntime(565): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.app.Activity.setContentView(Activity.java:1647)
05-06 11:27:23.043: E/AndroidRuntime(565): at test.pl.pl.TestjmkapActivity.onCreate(TestjmkapActivity.java:13)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-06 11:27:23.043: E/AndroidRuntime(565): ... 11 more
05-06 11:27:23.043: E/AndroidRuntime(565): Caused by: java.lang.ClassNotFoundException: com.google.maps.MapView in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/test.pl.pl-2.apk]
05-06 11:27:23.043: E/AndroidRuntime(565): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
05-06 11:27:23.043: E/AndroidRuntime(565): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
05-06 11:27:23.043: E/AndroidRuntime(565): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
05-06 11:27:23.043: E/AndroidRuntime(565): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
05-06 11:27:23.043: E/AndroidRuntime(565): ... 20 more
問題はどこだ?