jd-alexander / Google-Directions-Android

This project allows you to calculate the route between two locations and displays it on a map.
https://play.google.com/store/apps/details?id=com.directions.sample
MIT License
979 stars 394 forks source link

java.lang.NullPointerException #35

Open nicolasjafelle opened 9 years ago

nicolasjafelle commented 9 years ago

Apparently shortestRoute is initialized in null when:

result != null but is 0
//Line 99 in AbstractRouting class
i$ = shortestRoute.getPoints().iterator(); // at this point shortestRoute is null
java.lang.NullPointerException: Attempt to invoke virtual method 'java.util.List com.directions.route.Route.getPoints()' on a null object reference
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at com.directions.route.AbstractRouting.onPostExecute(AbstractRouting.java:146)
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at com.directions.route.AbstractRouting.onPostExecute(AbstractRouting.java:20)
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at android.os.AsyncTask.finish(AsyncTask.java:636)
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at android.os.AsyncTask.access$500(AsyncTask.java:177)
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:653)
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135)
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5254)
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372)
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-08 15:02:07.212 6045-6045/ai.home E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
jd-alexander commented 9 years ago

Okay. Would be nice if you submit a PR to fix the issue. Currently working on releasing my app (wakesocialapp.com) so can't touch this as yet

nicolasjafelle commented 9 years ago

Sure!! Probably first I need to fix it locally in the project I am using the library and then create the pull request =D.

jd-alexander commented 9 years ago

Awesome thanks.

jd-alexander commented 9 years ago

Still looking forward to the PR Nicolas ^_^