Skip to content

NullPointerException #44

@athkalia

Description

@athkalia

Hello, I am getting a NullPointerException from your library. Unfortunately the code is obfuscated so I can't trace it down 100%

java.lang.NullPointerException: Attempt to invoke virtual method 'double org.json.JSONObject.optDouble(java.lang.String)' on a null object reference
    at com.survivingwithandroid.weather.lib.provider.openweathermap.OpenweathermapProvider.getCurrentCondition(SourceFile:1516)
    at bno.onResponse(SourceFile:380)
    at bkr.execute(SourceFile:162)
    at com.squareup.okhttp.internal.NamedRunnable.run(SourceFile:33)
    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)

Edit:

We are getting the exception because the response is a weird openweathermap response, error 401 that can't be parsed by your library. The easiest way to fix this is to catch NullpointExceptions and return an empty weather object.

The json we receive is:
{"cod":401, "message": "Invalid API key. Please see http://openweathermap.org/faq#error401 for more info."}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions