Pheonix
Pheonix

Reputation: 6052

Jar and Android

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.

Upvotes: 0

Views: 684

Answers (2)

user377628
user377628

Reputation:

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.

Upvotes: 0

CommonsWare
CommonsWare

Reputation: 1006549

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

Upvotes: 2

Related Questions