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

Android Build a Blog Reader Android App Getting Data from the Web Moving Work from the Main Thread to an AsyncTask

paul eastman
paul eastman
1,301 Points

I've now started have issues running any code (issue states : W/EGL_emulation﹕ eglSurfaceAttrib not implemented)

I think this is something to do with an emulator issue more than the project issue. I'm using Studio 1.0.2 and this issue has only just started today. I've tried to create a virtual device with both "use host GPU" checked and unchecked and with different API levels etc...

Logcat text:

01-08 15:16:51.465 2273-2289/com.pg.eastmanpd.blogreader W/EGL_emulation﹕ eglSurfaceAttrib not implemented 01-08 15:16:51.466 2273-2289/com.pg.eastmanpd.blogreader W/OpenGLRenderer﹕ Failed to set EGL_SWAP_BEHAVIOR on surface 0xa6c9e740, error=EGL_SUCCESS

paul eastman
paul eastman
1,301 Points

FYI - I was initially getting "timeout" errors when trying to connect to the blog.treamtreehouse site so I've pointed it at google to test that.

My code is below. I've added a log just before the "URL blogFeedURL" deceleration, and can see from the debugger that the warnings are show at that point.

Situation 1: when trying to connect to google.com my code gets permanently stuck in the connection.connect(); line. No exceptions are thrown and no errors... it just stops. I never get to to Log.i line...

Situation 2: when trying to connect to blog.teamtreehouse... site I get both the warning RE eglSurfaceAttrib and then I get an IOException caught (see logcat paste below).

CODE: try { Log.i(TAG, "About to create URL"); URL blogFeedURL = new URL("http://www.google.com");

            //URL blogFeedURL = new URL("http://blog.teamtreehouse.com/api/get_recent_summary/?count=" + NUMBER_OF_POSTS);

            HttpURLConnection connection = (HttpURLConnection) blogFeedURL.openConnection();
            connection.connect();
            responseCode = connection.getResponseCode();
            Log.i(TAG, "Code:" + responseCode);

        }

Logcat: trying to point at the blog.teamtreehouse site

01-08 15:49:52.411 2581-2596/com.pg.eastmanpd.blogreader E/MainListActivity﹕ IO Exception caught java.net.ConnectException: failed to connect to blog.teamtreehouse.com/23.253.147.2 (port 80): connect failed: ETIMEDOUT (Connection timed out) at libcore.io.IoBridge.connect(IoBridge.java:124) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:456) at java.net.Socket.connect(Socket.java:882) at com.android.okhttp.internal.Platform.connectSocket(Platform.java:139) at com.android.okhttp.Connection.connect(Connection.java:148) at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:276) at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211) at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373) at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106) at com.pg.eastmanpd.blogreader.MainListActivity$GetBlogPostsTask.doInBackground(MainListActivity.java:70) at com.pg.eastmanpd.blogreader.MainListActivity$GetBlogPostsTask.doInBackground(MainListActivity.java:59) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:818) Caused by: android.system.ErrnoException: connect failed: ETIMEDOUT (Connection timed out) at libcore.io.Posix.connect(Native Method) at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:111) at libcore.io.IoBridge.connectErrno(IoBridge.java:137) at libcore.io.IoBridge.connect(IoBridge.java:122)             at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183)             at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:456)             at java.net.Socket.connect(Socket.java:882)             at com.android.okhttp.internal.Platform.connectSocket(Platform.java:139)             at com.android.okhttp.Connection.connect(Connection.java:148)             at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:276)             at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)             at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373)             at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)             at com.pg.eastmanpd.blogreader.MainListActivity$GetBlogPostsTask.doInBackground(MainListActivity.java:70)             at com.pg.eastmanpd.blogreader.MainListActivity$GetBlogPostsTask.doInBackground(MainListActivity.java:59)             at android.os.AsyncTask$2.call(AsyncTask.java:288)             at java.util.concurrent.FutureTask.run(FutureTask.java:237)             at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)             at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)             at java.lang.Thread.run(Thread.java:818)