how do i figure out how to debug this? HttpResponse

I'm trying to make a json object from the result of the googleplaces api. But one line of code is causing me alot of problems. My question is how the heck do i find what the issue is. I can't seem to catch the right exception (im a noob at debugging though). The url that i am passing in has the value: https://maps.googleapis.com/maps/api/place/search/json?location=34.7,-86.5&radius=16000&types=food&name=mcdonalds&sensor=true&key=(myApiCodeWhichImNOTPostingHere)

^i do have the correct apicode and the link works ourside of android.

here is the method in question (highlighted is the line that is causing problems).

public static JSONObject getTheJSON(String url){ JSONObject json=null; try{ DefaultHttpClient myHttpClient = new DefaultHttpClient(); HttpPost myHttpPost = new HttpPost(url); //this line below is giving me problems (jumps streight to the catch Exception) HttpResponse response = myHttpClient.execute(myHttpPost); //this line above is giving me problems(jumps streight to the catch Exception) String data = EntityUtils.toString(response.getEntity()); json= new JSONObject(data); //parse the JSONObject } catch (UnsupportedEncodingException e){e.printStackTrace();} catch (ClientProtocolException e){e.printStackTrace();} catch (IOException e){e.printStackTrace();} catch (JSONException e) {e.printStackTrace();} catch (NullPointerException e){ Log.e("My APP", "exception: " + e.getMessage());} /* jumps to line below (skips the other catch exceptions) the log reads "null" since i use the "getMessage()" so thats not useful*/ catch (Exception e ) { Log.e("My APP", "exception: " + e.getMessage());} return json; // returning the JSON object }

(Edit): Here is the logcat. i think im getting a connection to factory client error

10-16 21:11:30.105: E/My APP(980): exception 10-16 21:11:30.345: E/MapActivity(980): Couldn't get connection factory client


Instead of using e.getMessage(), use e.printStackTrace() (outside of the Log.e() method, but within the catch clause) so you can trace what the real problem is. If you do not get any wiser from that, please post the stacktrace here.

Edit (see commments):

My LogCat (without filters) always displays the stacktraces in a correct way, but after a bit of searching it seems that that is not always the case: See this SO question.

You should use three(!) arguments with the Log.e method. Example:

Log.e("My APP", "exception", e);


You might want to check your SSL setup. You are calling a https:// url


I ran your code in eclipse and it ran fine giving me a valid response. I think this is probably SSL related. You could enable SSL debugging by doing -Djavax.net.debug=all

Can you paste the output log after enabling SSL debugging?


  • Facebook Integration, iPhone
  • how do i figure out how to debug this? HttpResponse
  • Android sensors and thread
  • Loading Google Maps API V3 asynchronously with dojo.io.script fails silently
  • Excel - Search through a column to find if text matches and count string
  • Passing string array to webservice method
  • Google Maps: Norwegian postcodes not returning any results
  • Excessive console messages from Kafka Producer
  • No dhtreader in java.library.path
  • Google Maps API v3 javascript Markers don't always load
  • Trouble opening utf-8 URI's with Ruby's 'open-uri'
  • Google directions api web service - show the response on map. Is it possible?
  • Eclipse > Javascript > Code highlighting not working with Object Notation
  • How to decode route points from the JSON Output Data?
  • UWP - Show textbox text highlight while textbox is out of focus
  • Samsung Galaxy Tab 10.1 and -webkit-tap-highlight-color style?
  • Get temperature from NVidia GPU using NVAPI
  • GDB skips over my code!
  • Is it possible to embed the sidebar with Google Maps?
  • Webgrid not refreshing after delete MVC
  • Jquery UI tool tip close icon
  • Disable Enter in editText android
  • Cannot resolve symbol 'MyApi'
  • Highlight one bar in a series in highcharts?
  • If I include Java 8 in my Android app does that affect which devices it will work on?
  • How to recover from a Spring Social ExpiredAuthorizationException
  • ILMerge & Keep Assembly Name
  • Trying to switch camera back to front but getting exception
  • Release, debug version and Authorization Google?
  • Large data - storage and query
  • WOWZA + RTMP + HTML5 Playback?
  • Traverse Array and Display in markup
  • Free memory of cv::Mat loaded using FileStorage API
  • JTable with a ScrollPane misbehaving
  • Angular 2 constructor injection vs direct access
  • Qt: Run a script BEFORE make
  • unknown Exception android
  • Programmatically clearing map cache
  • failed to connect to specific WiFi in android programmatically
  • How can I use threading to 'tick' a timer to be accessed by other threads?