0
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String org.jsoup.nodes.Element.ownText()' on a null object reference

Here is My Code:

public class VersionChecker extends AsyncTask<String, String, String> {

    private String newVersion;

    @Override
    protected String doInBackground(String... params) {

        try {
            newVersion = Jsoup.connect("https://play.google.com/store/apps/details?id=" + BuildConfig.APPLICATION_ID + "&hl=en")
                    .timeout(30000)
                    .userAgent("Mozilla/5.0 (Windows; U; WindowsNT 5.1; en-US; rv1.8.1.6) Gecko/20070725 Firefox/2.0.0.6")
                    .referrer("http://www.google.com")
                    .get()
                    .select("div[itemprop=softwareVersion]")
                    .first()
                    .ownText();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return newVersion;
    }
}
takendarkk
  • 3,178
  • 7
  • 23
  • 36
  • 5
    Possible duplicate of [What is a NullPointerException, and how do I fix it?](https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it) – takendarkk Apr 09 '18 at 13:49
  • 'first()' is returning null which it can if prior 'select' produced no results (empty list). –  Apr 09 '18 at 16:08

1 Answers1

-1

Android playstore updated their UI, so trying to select the current version: from the unparsed html is returning null - an alternative will need to be used

  • Pls share such info in comments and not answers. Answers are only used when you have a solution to the problem. Comments can be used for clarification or telling such info. – Archit Gargi Jun 04 '22 at 03:09