how to use htmlunit with my android project

I have downloaded htmlunit 2.11 zip. i have extract it. then i have tried to paste them in my project's libs folder. from the libs folder i have added them in build path. then i get this error, while i was trying to run my app

conversion to dalvik format failed with error 1

then, from stackoverflow i found that, one said to delete xalan xercesImpl xml-apis. i deleted them. but getting this error:

Error generating final archive: Found duplicate file for APK: about.html

error message also showed that which files are conflicted. they are jetty-http jetty-io jetty-util jetty-websocket then i run my app again. this time it shows some warning. i have ignored them. but my app crash saying that classNotFound

by the way, i have also deleted httpclient jar. because one said that httpclient is already built in android.

this is my problem. Now, can anyone help me? i really want to use htmlunit in my app

Edited:

it will be very helpfull if you show me the steps, 'how to add htmlunit in my project'

Edited 2:

mainly i have a link, which i have get after login (i have login through web view) this link give me a simple page. in that page there is a textarea and a submit button. and there are some javascript too (i think these javascript run, when i press the submit button). i can do it through webview, but for some reason i don't want to use webview. whene i press submit button, it deliver the value of textarea and some value of hidden field with existing cookies(which are get when i logged in through webview) Post method. i need to do this without webview. now is there any other option beside htmlunit ?? i heard about HttpClient, HttpUrlConnection. one more thing, agter submitting it will redirect me to another page. i don't need to do anything with this redirected page.

N.B: if this question is not appropriate with what i really ask previously, then you can suggest me, and i will post a new question. thank you


Solution 1:

Nothing of this will work because he is trying to include HtmlUnit into a android project. HtmlUnit is not compatible with android because is refernces some java.* & javax.* classes which are not available in android.

Hope there will come a version for android.

Solution 2:

sorry, i have lost all my hope on HTMLUNIT. :( to gain my goal i have used HttpUrlConnection & Jsoup ... that works for me. here is my procedure i have post my code in answer.

Solution 3:

Here are the steps to follow:

  1. Download the latest version of HtmlUnit from http://sourceforge.net/projects/htmlunit/files/htmlunit/2.11/
  2. Unzip downloaded file
  3. Go to lib folder --> Right click on htmlunit-core-js-2.11.jar and select 'copy'
  4. Go to Package Explorer in Eclicse --> Chose your project --> Right click on libs folder and select 'paste'
  5. Right click on the newly added file and click on 'Add as a library...' and select your project.
  6. Repeat steps 3, 4 and 5 for the htmlunit-2.11.jar file
  7. Add this two imports to your project:

    import com.gargoylesoftware.htmlunit.WebClient;

    import com.gargoylesoftware.htmlunit.html.HtmlPage;

  8. Clean the project.

Please also check this link http://www.aviyehuda.com/blog/2011/05/16/htmlunit-a-quick-introduction/ for the htmlUnit quick introduction