Crbreingan
Crbreingan

Reputation: 639

Hello Google Maps Example NULL Pointer Exception

I am creating a google maps application for android and I am following the guide at http://developer.android.com/resources/tutorials/views/hello-mapview.html to get started.

I can run the app just fine in my emulator, but when I click on the overlay item I get a NULL Pointer Exception. The trace is below. I'm new to Android and have no idea how to debug this. So any help would be greatly appreciated.

12-20 02:57:05.898: W/dalvikvm(473): threadid=1: thread exiting with uncaught exception (group=0x40015560)
12-20 02:57:05.928: E/AndroidRuntime(473): FATAL EXCEPTION: main
12-20 02:57:05.928: E/AndroidRuntime(473): java.lang.NullPointerException
12-20 02:57:05.928: E/AndroidRuntime(473):  at com.android.internal.app.AlertController$AlertParams.<init>(AlertController.java:742)
12-20 02:57:05.928: E/AndroidRuntime(473):  at android.app.AlertDialog$Builder.<init>(AlertDialog.java:273)
12-20 02:57:05.928: E/AndroidRuntime(473):  at hello.google.maps.HelloItemizedOverlay.onTap(HelloItemizedOverlay.java:41)
12-20 02:57:05.928: E/AndroidRuntime(473):  at com.google.android.maps.ItemizedOverlay.onTap(ItemizedOverlay.java:453)
12-20 02:57:05.928: E/AndroidRuntime(473):  at com.google.android.maps.OverlayBundle.onTap(OverlayBundle.java:83)
12-20 02:57:05.928: E/AndroidRuntime(473):  at com.google.android.maps.MapView$1.onSingleTapUp(MapView.java:356)
12-20 02:57:05.928: E/AndroidRuntime(473):  at com.google.android.maps.GestureDetector.onTouchEvent(GestureDetector.java:533)
12-20 02:57:05.928: E/AndroidRuntime(473):  at com.google.android.maps.MapView.onTouchEvent(MapView.java:683)
12-20 02:57:05.928: E/AndroidRuntime(473):  at android.view.View.dispatchTouchEvent(View.java:3885)
12-20 02:57:05.928: E/AndroidRuntime(473):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
12-20 02:57:05.928: E/AndroidRuntime(473):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
12-20 02:57:05.928: E/AndroidRuntime(473):  at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
12-20 02:57:05.928: E/AndroidRuntime(473):  at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
12-20 02:57:05.928: E/AndroidRuntime(473):  at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
12-20 02:57:05.928: E/AndroidRuntime(473):  at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
12-20 02:57:05.928: E/AndroidRuntime(473):  at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
12-20 02:57:05.928: E/AndroidRuntime(473):  at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194)
12-20 02:57:05.928: E/AndroidRuntime(473):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
12-20 02:57:05.928: E/AndroidRuntime(473):  at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 02:57:05.928: E/AndroidRuntime(473):  at android.os.Looper.loop(Looper.java:130)
12-20 02:57:05.928: E/AndroidRuntime(473):  at android.app.ActivityThread.main(ActivityThread.java:3683)
12-20 02:57:05.928: E/AndroidRuntime(473):  at java.lang.reflect.Method.invokeNative(Native Method)
12-20 02:57:05.928: E/AndroidRuntime(473):  at java.lang.reflect.Method.invoke(Method.java:507)
12-20 02:57:05.928: E/AndroidRuntime(473):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
12-20 02:57:05.928: E/AndroidRuntime(473):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
12-20 02:57:05.928: E/AndroidRuntime(473):  at dalvik.system.NativeStart.main(Native Method)

Thanks!

Upvotes: 1

Views: 881

Answers (3)

Pepper Yan
Pepper Yan

Reputation: 1

Maybe you use the one-param constructor like I did,But theAlertDialog.Builder need a instantiated object,which you may forget to do.

Upvotes: 0

sschrass
sschrass

Reputation: 7166

generally speaking, try to catch exceptions and make use of Log and TAG. http://developer.android.com/reference/android/util/Log.html. This helped me a lot!

A basic tutorial: http://www.androidza.co.za/beyond-hello-world-logcat-and-exception-handling/

Upvotes: 0

Related Questions