Search code examples
javaandroidhtmlunitnoclassdeffounderror

HtmlUnit Android Error


This is my first time using HtmlUnit and I am using it within the Android SDK (not sure if thats even possible, if so then stop me now)

So I keep getting an error that seems to be linked to the WebClient:

06-01 22:46:58.939: ERROR/AndroidRuntime(351): Uncaught handler: thread main exiting due to uncaught exception
06-01 22:46:58.969: ERROR/AndroidRuntime(351): java.lang.NoClassDefFoundError: com.gargoylesoftware.htmlunit.DefaultCssErrorHandler
06-01 22:46:58.969: ERROR/AndroidRuntime(351):     at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:154)
06-01 22:46:58.969: ERROR/AndroidRuntime(351):     at com.gargoylesoftware.htmlunit.WebClient.<init>(WebClient.java:176)
06-01 22:46:58.969: ERROR/AndroidRuntime(351):     at com.laytproducts.songmaster.mainAct.showResults(mainAct.java:107)
06-01 22:46:58.969: ERROR/AndroidRuntime(351):     at com.laytproducts.songmaster.mainAct$1.onClick(mainAct.java:90)

This is my method it is referring to:

public void showResults(String endText) throws Exception{
        WebClient webClient = new WebClient(); //ERROR ON THIS LINE
        HtmlPage page = webClient.getPage(baseSite+endText);
        HtmlTable resultsT = page.getHtmlElementById("results");
        int i = 0;
        for(final HtmlTableRow row : resultsT.getRows()){
            Toast.makeText(getApplicationContext(), "Getting Results...", Toast.LENGTH_SHORT).show();
            for(final HtmlTableCell cell : row.getCells()){
                results[i] = cell.asText();
                i++;
            }
        }
    }

What is happening? Like I said, I am new to HtmlUnit and have no idea what that means. I was thinking that there was a problem with Android + WebClient?

I searched my error and found out what it means a little, but not how I can fix it. (The WebClient is trying to run as a class?)

Hopefully I can get this figured out quickly, thanks.

-Brandon


Solution

  • take a look at htmlunit dependencies (go to their website) .

    You are missing a jar file