1

I have gone through Google's MapView tutorial and it works fine on the emulator and for example on my HTC Flyer. But for some reason it immediately crashes when starting it on my mobile phone (Samsung Galaxy I9000).

The crash happens there, because right at the beginning the Bundle that onCreate() receives is null. I'm compiling against Android 2.3.3. This is installed on the phone as well. The Flyer uses Android 3.0

I'd greatly appreciate any help on this weird issue.

This is the excact Logcat output:

04-18 10:52:26.019: E/AndroidRuntime(1461): FATAL EXCEPTION: main
04-18 10:52:26.019: E/AndroidRuntime(1461): java.lang.RuntimeException: Unable to start activity ComponentInfo{bernd.konnerth/bernd.konnerth.HelloMapViewActivity}: java.lang.NullPointerException
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android.os.Looper.loop(Looper.java:123)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android.app.ActivityThread.main(ActivityThread.java:3687)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at java.lang.reflect.Method.invokeNative(Native Method)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at java.lang.reflect.Method.invoke(Method.java:507)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at dalvik.system.NativeStart.main(Native Method)
04-18 10:52:26.019: E/AndroidRuntime(1461): Caused by: java.lang.NullPointerException
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android.app.ContextImpl.openFileOutput(ContextImpl.java:495)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android.content.ContextWrapper.openFileOutput(ContextWrapper.java:158)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android_maps_conflict_avoidance.com.google.common.io.android.AndroidPersistentStore.writeBlockX(AndroidPersistentStore.java:140)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android_maps_conflict_avoidance.com.google.common.io.android.AndroidPersistentStore.writeBlock(AndroidPersistentStore.java:169)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android_maps_conflict_avoidance.com.google.common.io.PreferenceStore.ensurePreferencesLoaded(PreferenceStore.java:178)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android_maps_conflict_avoidance.com.google.common.io.PreferenceStore.readPreference(PreferenceStore.java:86)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android_maps_conflict_avoidance.com.google.common.io.BasePersistentStore.readPreference(BasePersistentStore.java:41)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android_maps_conflict_avoidance.com.google.common.StaticUtil.readPreferenceAsDataInput(StaticUtil.java:271)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.loadOrRequestCookie(DataRequestDispatcher.java:493)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.<init>(DataRequestDispatcher.java:390)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android_maps_conflict_avoidance.com.google.googlenav.datarequest.DataRequestDispatcher.createInstance(DataRequestDispatcher.java:341)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at com.google.android.maps.MapActivity.createMap(MapActivity.java:548)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at com.google.android.maps.MapActivity.onCreate(MapActivity.java:422)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at bernd.konnerth.HelloMapViewActivity.onCreate(HelloMapViewActivity.java:15)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-18 10:52:26.019: E/AndroidRuntime(1461):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
04-18 10:52:26.019: E/AndroidRuntime(1461):     ... 11 more

Thanks, Bernd

Bernd
  • 675
  • 2
  • 8
  • 30
  • what is the Logccat output exactly? – Paresh Mayani Apr 18 '12 at 08:42
  • I've added it above now. – Bernd Apr 18 '12 at 09:03
  • see this [example](http://android-example-code.blogspot.in/p/map-api-in-android.html) will help you... – MAC Apr 18 '12 at 08:40
  • Thanks, i will try. But somehow the **mains.xml** seems to be missing, which is referenced in **setContentView(R.layout.mains)** – Bernd Apr 18 '12 at 09:06
  • put this in ur mains.xml – MAC Apr 18 '12 at 09:44
  • I got a solution! Obviously the package name needs to start with **com.**. I would like to explain in detail, but why the hell am I not allowed to answer my own question within 8 hours ??? – Bernd Apr 18 '12 at 10:16
  • I haven't tried it, because I found the solution mentioned above. But when I look into that example I see that **march.fifteen** was used as package name. So the example would probably not have worked as well. Nevertheless, thanks for your fast reply! – Bernd Apr 18 '12 at 11:26

1 Answers1

3

I got it! Guess what! It's the package name that matters!!!

I found a Google Map sample in:

C:\android-sdk\add-ons\addon-google_apis-google_inc_-10\samples\MapsDemo

then I stripped it down until it was nearly identical to my one. I was using bernd.konnerth as the package name. But for some really crazy reason, obviously the Samsung phone (and probably other devices as well) does not accept that and simply throws a NullPointerException at launch, without any further hint that could point to the package name issue.

When I use com.bernd.konnerth everything works fine. Obviously there must be a com. in front. But be warned! There seem to be further name combinations that don't work. By chance I found out that for example com.android.wifi doesn't work as well! Even thought this package does NOT seem to exist in android namespace.

Such things can really drive people crazy! :-(

Nevertheless thanks for all of your fast replies!

Bernd

Bernd
  • 675
  • 2
  • 8
  • 30