Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Yasser Mohammed
10,247 PointsBlogReader Unknown Host error
I am at the "Moving Work from the Main Thread to an AsyncTask" in the Getting Data from the Web section of the blog reader app. Upon running the code I get a UnknownHostException stating "Unable to resolve host :"blog.teamtreehouse.com": No address associated with host name.
Running the blog link on my browser returns a status 'ok'. Just wondering if I was doing something wrong in the code.
1 Answer
Ben Jakuben
Treehouse TeacherCan you paste in your exact code? It should have "http://" at the front, for example. Maybe we can troubleshoot it if we see how it's being used.
Yasser Mohammed
10,247 PointsYasser Mohammed
10,247 PointsHere's the code from my MainListActivity.java which I am using currently. I got the same error even after importing the project files provided in that section into the eclipse and running it. I wonder if it's an error in my environment (I'm using the AndroidSDK 4,3 on windows).
Another thing I wanted to point out in the Log.e methods. Log.e(TAG, "Exception caught: ", e) only prints "Exception caught: " in LogCat. I concatenated the exception variable with the second argument to actually view the exception in LogCat. Dunno if you intended to just show it that way but I thought this would help debug the exceptions better so I pointed it out :)
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherI wonder...could you fire up your emulator, open the browser, and type in the blog URL from your code?
http://blog.teamtreehouse.com/api/get_recent_summary/?count=20
If it works from the emulator then you would know it is a problem with the code. If the emulator cannot reach that URL, then it would indicate a problem with your setup (maybe a firewall or proxy or something else in network settings).
Yasser Mohammed
10,247 PointsYasser Mohammed
10,247 PointsFinally figured out the problem It was all because I had switched from one wifi to another and had left the emulator running. I guess the emulator does not reconfigure its internet settings with that change. Restarting the emulator solved the issue.
Thanks! Looking forward to more projects soon
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherHaha - that's a funny and frustrating error! Seems like it should totally just piggyback on your computer's connection.
If you're interested, check out GenyMotion for Android emulators. I just downloaded and installed it the other night but haven't actually tried it out yet. A lot of Android developers in my Twitter feed really seem to like it, though.
Ernest Grzybowski
Treehouse Project ReviewerErnest Grzybowski
Treehouse Project ReviewerBen Jakuben I've heard very good things about GenyMotion, but I haven't actually tried it out as well. The upside of the "slowness" of the emulator is definitely seeing potential bottlenecks that I wouldn't normally notice. Very helpful with the application I'm currently working on.
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherHaha - that's a great way to spin that as a positive.
It's really useful to simulate slow network speeds, too!