0

I an trying to use a JAR file in my Android project but i am consistently getting error. The error has been referenced here on SO many times, but none of the solutions are working for me.

I am using this jar : http://htmlcleaner.sourceforge.net/index.php

I am using IntelliJ IDE.

I have tried a combination of the following settings :

in AndroidManifest.xml, one of the following line (not both at the same time)

<uses-library android:name="org.htmlcleaner.HtmlCleaner"/>
<uses-library android:name="org.htmlcleaner"/>

i copied the JAR file to my libs/ folder and ran it, i get : INSTALL_FAILED_MISSING_SHARED_LIBRARY

I tried Adding Jar file through Project Structure Setting in various places

Project Structure -> Module -> Dependencies -> Add -> Jar -> jar file
Project Structure -> Module -> Dependencies -> Add -> Library -> New Library -> jar file / lib dir

Project Structure -> Libraries -> Add -> jar file

None of this solves the problem.

I als tried by removing the

I am having this problem with every JAR file.

My AVD setting :

Platform 2.3.1
API Level 9
Not using Any Google Maps

Please help me out.

Pheonix
  • 6,049
  • 6
  • 30
  • 48
  • When you say 'Jar', do you mean one that's supposed to be executable by the JVM, i.e. contains .class files? Or does it contain the .java source? –  Apr 16 '12 at 22:28
  • The answer in this thread http://stackoverflow.com/questions/2188049/parse-html-in-android pointed me to http://java-source.net/open-source/html-parsers from which i am using htmlcleaner ... the htmlcleaner.jar has .class files inside it. – Pheonix Apr 16 '12 at 22:32

2 Answers2

2

Delete the <uses-library> elements, as they are not used for third-party JARs.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

Java byte code compiled for a desktop JVM won't work on Android. You need to compile the Java source using the Dalvik compiler to produce .dx files, which are executable by the Dalvik VM on Android.

edit: to compile the java source, get the jar file with the source code, extract, then add the .java files to your build path. I'm not sure how to add to the build path in IntilliJ, but in eclipse, it's as simple as right-clicking, and clicking 'include' (or importing). This will compile the library's code along with your own.

  • Then why do no answers in this question http://stackoverflow.com/questions/2188049/parse-html-in-android state anything like that ? that question spefically states Android, Did i accidently choose the wrong Library ? – Pheonix Apr 16 '12 at 22:38
  • Hmm.. maybe I'm wrong and it is possible. However, I know that if you just add the java files to your project (perhaps add the entire package), you can easily compile the whole thing into an Android app. –  Apr 16 '12 at 22:42