Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Build a Weather App Networking Making an HTTP GET Request with OkHttp

Fatal Error creating OkHTTP3 object

I've pretty much finished this library, but I've gotten a fatal error from one of the beginning stages in this video. I've isolated it down to this little bit of introductory code.

import okhttp3.OkHttpClient;

public class MainActivity extends AppCompatActivity {

protected void onCreate(Bundle savedInstanceState) {

    String URL = "https://api.darksky.net/forecast/****(secret-key)*****/37.8267,-122.4233";

    OkHttpClient client = new OkHttpClient();

Whenever I create the OkHTTPClient object or a Request object or anything at all from the OkHTTP3 library it crashes the program. The debugger says: "A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x68 in tid 18904 (xample.weather2), pid 18904 (xample.weather2)"

Then it states: "Cause: null pointer dereference" and proceeds to list off a ton of errors from memory and backtraces tons more errors from stuff in a directory called /system/libart64.

I'd really appreciate any help on this, because I've been scouring StackOverFlow and Google for days and can't find much help. Oh and yes, I've added the " implementation 'com.squareup.okhttp3:okhttp:3.14.1" to the gradle(Module:app), I've added the user-permission to the internet, and I've updated the minSDKversion and synced the new gradle build.

Thanks in advance!

2 Answers

Hi. Make sure you're using Java 8 with this version of the OkHttp library.

If you aren't, just add

android {
 // (...)
 compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8

in your build.gradle(Module: app) file.

Hope that helps :)

Omg it worked. Thank you so much. I don't think I would've ever figured that out.

You're welcome. I'm glad it worked :)