2012-05-06 7 views
0

mapViewに問題があります。これはコードです: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 

どこに問題がありますか?

+0

すべてがどのようなエミュレータについて、正常に見えますか? Google Maps API 8にエミュレータを使用していますか? – Habib

+0

はい。エミュレータはgoogle api Api8 – edi233

+0

で削除して新しいエミュレータを作成してみましたか? – Habib

答えて

2

たぶんのXMLのMapViewにこの行は、それが失敗します:

xmlns:android="http://schemas.android.com/apk/res/android" 
+0

この行がありません同じエラーが表示されます – edi233

+0

@ edi233 google api v8ではなく、アンドロイドv8を使用しないでください。プロジェクトのクリーンアップ、プロジェクトの修正、ビンの削除、プロジェクトのリフレッシュ。 – Warpzit

+1

ああ、 Warpzit