Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempt to invoke virtual method 'int java.lang.String.hashCode()'

I'm trying to load images from URL into girdview using Volley Library. For this I'm following this tutorial. When I run my project, it collects all URLs from server database and then store in arraylist. But doesn't displays images. And I am getting java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference error. It doesn't even point to any line number of code where I'm getting this error. See below Logcat Output :

java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.hashCode()' on a null object reference
        at com.android.volley.Request.<init>(Request.java:136)
        at com.android.volley.toolbox.ImageRequest.<init>(ImageRequest.java:71)
        at com.android.volley.toolbox.ImageLoader.get(ImageLoader.java:219)
        at com.android.volley.toolbox.ImageLoader.get(ImageLoader.java:171)
        at com.android.volley.toolbox.NetworkImageView.loadImageIfNecessary(NetworkImageView.java:141)
        at com.android.volley.toolbox.NetworkImageView.onLayout(NetworkImageView.java:190)
        at android.view.View.layout(View.java:15596)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
        at android.view.View.layout(View.java:15596)
        at android.view.ViewGroup.layout(ViewGroup.java:4966)
        at android.widget.GridView.setupChild(GridView.java:1542)
        at android.widget.GridView.makeAndAddView(GridView.java:1436)
        at android.widget.GridView.makeRow(GridView.java:361)
        at android.widget.GridView.fillDown(GridView.java:302)
        at android.widget.GridView.fillFromTop(GridView.java:437)
        at android.widget.GridView.layoutChildren(GridView.java:1276)
        at android.widget.AbsListView.onLayout(AbsListView.java:2148)
        at android.view.View.layout(View.java:15596)
        at android.view.ViewGroup.layout(ViewGroup.java:4966)
        at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1703)
        at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1557)
        at android.widget.LinearLayout.onLayout(LinearLayout.java:1466)
        at android.view.View.layout(View.java:15596)
        at android.view.ViewGroup.layout(ViewGroup.java:4966)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
        at android.widget.ScrollView.onLayout(ScrollView.java:1502)
        at android.view.View.layout(View.java:15596)
        at android.view.ViewGroup.layout(ViewGroup.java:4966)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
        at android.view.View.layout(View.java:15596)
        at android.view.ViewGroup.layout(ViewGroup.java:4966)
        at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:494)
        at android.view.View.layout(View.java:15596)
        at android.view.ViewGroup.layout(ViewGroup.java:4966)
        at android.widget.FrameLayout.layoutChildren(FrameLayout.java:573)
        at android.widget.FrameLayout.onLayout(FrameLayout.java:508)
        at android.view.View.layout(View.java:15596)
        at android.view.ViewGroup.layout(ViewGroup.java:4966)
        at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2072)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1829)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1054)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5779)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:767)
        at android.view.Choreographer.doCallbacks(Choreographer.java:580)
        at android.view.Choreographer.doFrame(Choreographer.java:550)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:753)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:135)
        at android.app.ActivityThread.main(ActivityThread.java:5221)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

Can anybody help me what is the exact problem and how do I solve this ?

like image 367
Ruchir Avatar asked Oct 13 '15 11:10

Ruchir


2 Answers

You should check the null values for the image where you are getting the data from the server.

like image 184
Avanish Singh Avatar answered Sep 19 '22 23:09

Avanish Singh


Getting string value as null, for this instance shows String.hashcode() error

like image 35
Gopi Cg Avatar answered Sep 19 '22 23:09

Gopi Cg