Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Everytime you look for an element with select("") your calling last() in a chain which assumes it will <strong>always</strong> find atleast 1 element, in the situation that there is no say "p" in the document, that is when you will encounter a crash.</p> <p>It's just simple NullPointerExceptions, you need to learn to code defensively:</p> <pre><code>// If you believe overview could be null if(overview != null){ ArrayList&lt;Element&gt; paragraphs = overview.select("p"); // Whatever type select(String) returns Element lastParagraph = null; if(paragraphs != null){ lastParagraph = paragraphs.last(); } else { // Deal with not finding "p" (lastParagraph is null in this situation) } // Continue with lastParagraph } else { // Deal with overview being null } </code></pre> <p><a href="http://www.javacoffeebreak.com/articles/toptenerrors.html" rel="nofollow">Number 1 Java Error</a> (scroll down)</p> <p>Also you shouldn't really wrap your code with a catch all Exception, try to catch each exception and deal with them individually.</p> <p>Lookup the API for your get() method <a href="http://jsoup.org/apidocs/org/jsoup/Connection.html#get%28%29" rel="nofollow">Jsoup get()</a> (eclipse tells you this anyway) It throws IOException, so you should <em>just</em> catch this.</p> <pre><code> try { doc = Jsoup.connect(url).get(); } catch (IOException e) { Log.e("Tag", "Jsoup get didn't get a document", e); } </code></pre> <p><a href="http://www.javacoffeebreak.com/articles/toptenerrors.html" rel="nofollow">Number 5 Java Error</a> (scroll down)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload