0

Basically, I have a large string of HTML. Inside, I have a span of class 'pageHeader'. I am having a ton of trouble just getting the app to open with the Jsoup parts added, let laone using the parsed parts of the HTML. To start, here are my imports:

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

After I get string html which is basically just one long string of HTML, I try to parse the document in my onCreate method:

try {
    Document doc = Jsoup.parse(html);
    Element span = doc.select("span.pageHeader").first();
    String text = span.attr("InnerText");
} catch(Exception e) {
    e.printStackTrace();
}

I've tried a few other things, but they're all mainly variants of that approach. It always crashes the emulator despite no viewable errors in Eclipse.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Mark Lyons
  • 1,354
  • 6
  • 21
  • 57
  • There must be some error/exceptions shown in logcat, whenever your app crash. Post logcat will help people investigate your problem. – yorkw Apr 01 '12 at 21:55
  • Here's the main error it seems: 04-01 23:55:43.677: E/AndroidRuntime(315): java.lang.NoClassDefFoundError: org.jsoup.Jsoup – Mark Lyons Apr 01 '12 at 23:56
  • 1
    What SDK version are you using? If using r17, make sure the jsoup.jar is in the libs directory. – yorkw Apr 02 '12 at 00:00
  • Pretty sure it's r17. I only downloaded it around 2 weeks ago and that looks to be the latest version. jsoup-1.6.2.jar is in the 'Referenced Libraries' directory. Should it be somewhere else? – Mark Lyons Apr 02 '12 at 00:05
  • Ok, makes sense. I just manually added the JAR before. I used the answer [here](http://stackoverflow.com/a/3642953/1103669) to correctly add the directory. – Mark Lyons Apr 02 '12 at 00:31

1 Answers1

1

I imported the directory incorrectly. If anyone has a similar problem (doubt it but oh well), refer to the excellent answer here.

Community
  • 1
  • 1
Mark Lyons
  • 1,354
  • 6
  • 21
  • 57