Salut

Je recontre quelques problèmes avec le MapView, alors que je n'ai fait qu'un simple copier/coller du code du tutoriel proposé sur le site.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 
import android.os.Bundle;
import android.util.Log;
 
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapController;
import com.google.android.maps.MapView;
 
public class GoogleMap extends MapActivity {
 
	private MapView mapView;
	private MapController mc;
	private GeoPoint location;
 
	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
 
		super.onCreate(savedInstanceState);
 
		this.mapView =  new MapView(this,this.getResources().getString(R.string.mapkey));
		Log.e("Gmap","new Map");
		this.mapView.setClickable(true);
 		this.mc = this.mapView.getController();
 		double latitude = 50.606;
 		double longitude = 3.15;
 		this.location = new GeoPoint((int) (latitude * 1000000.0),(int) (longitude * 1000000.0));
 		Log.e("Gmap","new Geopoint");
		this.mc.setCenter(this.location);
 		this.mc.setZoom(17);
 		this.mapView.setSatellite(true);
 		Log.e("Gmap","setSatellite");
 		this.mapView.invalidate();
 
		this.setContentView(this.mapView);
   	}
 
	public GeoPoint getLocation() {
		return location;
	}
 
	public void setLocation(GeoPoint location) {
		this.location = location;
		this.mc.setCenter(this.location);
		this.mapView.invalidate();
	}
 
	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}
}
Le problème vient de la ligne suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
		super.onCreate(savedInstanceState);
et voici ce que m'affiche le LogCat
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 
04-22 11:57:30.746: ERROR/AndroidRuntime(2221): ERROR: thread attach failed
04-22 11:57:32.196: ERROR/AndroidRuntime(2229): ERROR: thread attach failed
04-22 11:57:32.436: ERROR/Context(2186): android.location.LocationManager@44ce6af8
04-22 11:57:42.556: ERROR/ActivityManager(89): fail to set top app changed!
04-22 11:58:17.236: ERROR/AndroidRuntime(2261): ERROR: thread attach failed
04-22 11:58:18.606: ERROR/AndroidRuntime(2269): ERROR: thread attach failed
04-22 11:58:19.126: ERROR/AndroidRuntime(2277): Uncaught handler: thread main exiting due to uncaught exception
04-22 11:58:19.146: ERROR/AndroidRuntime(2277): java.lang.RuntimeException: Unable to start activity ComponentInfo{android.gmap/android.gmap.GoogleMap}: java.lang.NullPointerException
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2596)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2621)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.app.ActivityThread.access$2200(ActivityThread.java:126)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1932)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.os.Looper.loop(Looper.java:123)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.app.ActivityThread.main(ActivityThread.java:4595)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at java.lang.reflect.Method.invokeNative(Native Method)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at java.lang.reflect.Method.invoke(Method.java:521)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at dalvik.system.NativeStart.main(Native Method)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277): Caused by: java.lang.NullPointerException
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.app.ApplicationContext.openFileOutput(ApplicationContext.java:405)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.content.ContextWrapper.openFileOutput(ContextWrapper.java:158)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.google.common.io.android.AndroidPersistentStore.writeBlockX(Unknown Source)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.google.common.io.android.AndroidPersistentStore.writeBlock(Unknown Source)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.google.common.io.PreferenceStore.ensurePreferencesLoaded(Unknown Source)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.google.common.io.PreferenceStore.readPreference(Unknown Source)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.google.common.io.BasePersistentStore.readPreference(Unknown Source)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.google.common.StaticUtil.readPreferenceAsDataInput(Unknown Source)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.google.googlenav.datarequest.DataRequestDispatcher.loadOrRequestCookie(Unknown Source)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.google.googlenav.datarequest.DataRequestDispatcher.<init>(Unknown Source)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.google.googlenav.datarequest.DataRequestDispatcher.createInstance(Unknown Source)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.google.android.maps.MapActivity.createMap(MapActivity.java:310)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at com.google.android.maps.MapActivity.onCreate(MapActivity.java:210)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.gmap.GoogleMap.onCreate(GoogleMap.java:21)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2544)
04-22 11:58:19.146: ERROR/AndroidRuntime(2277):     ... 11 more
04-22 11:58:19.236: ERROR/ActivityManager(89): fail to set top app changed!