0

I am trying to use a JAR I exported in Eclipse in an Android Studio project. The problem is the way the libs work out:

My custom API jar depends on 2 main .jar libraries, those 2 .jar libraries then depend on a dozen more .jar libraries. All of these libraries were in my libs folder in my Eclipse project and they worked perfectly fine in Eclipse, but once I exported my custom jar (with the other jars included in the larger jar), I ended up getting errors regarding some classes not being accessible.

In Eclipse I exported as a JAR File (not executable), and the manifest file is empty. However, if I try to populate the Class-Path attribute in the manifest file, I either get errors from Eclipse while exporting, or (if I edit the manifest externally and then add it in after exporting from Eclipse), Android Studio still gives access errors.

This is my manifest file (the one in my custom library) that I repackage into the library:

Manifest-Version: 1.0
Class-Path: 
libs/jsoup-1.10.2.jar
libs/commons-codec-1.9.jar
libs/commons-io-2.5.jar
libs/commons-lang3-3.5.jar
libs/commons-logging-1.2.jar
libs/cssparser-0.9.22.jar
libs/htmlunit-2.26.jar
libs/htmlunit-core-js-2.26.jar
libs/httpclient-4.5.3.jar
libs/httpcore-4.4.6.jar
libs/httpmime-4.5.3.jar
libs/jetty-client-9.4.3.v20170317.jar
libs/jetty-http-9.4.3.v20170317.jar
libs/jetty-io-9.4.3.v20170317.jar
libs/jetty-util-9.4.3.v20170317.jar
libs/neko-htmlunit-2.25.jar
libs/sac-1.3.jar
libs/serializer-2.7.2.jar
libs/websocket-api-9.4.3.v20170317.jar
libs/websocket-client-9.4.3.v20170317.jar
libs/websocket-common-9.4.3.v20170317.jar
libs/xalan-2.7.2.jar libs/xercesImpl-2.11.0.jar
libs/xml-apis-1.4.01.jar

How can I get my code to compile? Is the manifest the problem? Thank you.

said
  • 474
  • 4
  • 8
  • 18
  • Are all those values on a single line separated by space(s) after Class-Path: ? If not they should be. – dave_thompson_085 Jun 14 '17 at 04:49
  • @dave_thompson_085 Apparently not. I get a.limr too long error if I try to out them all on one line. Apparently this is how you do it in that case. – said Jun 14 '17 at 11:02

1 Answers1

0

I ended up moving the libs out of the jar and into the main libs folder which solved half the issue. The other half is that you can't use HTMLUnit on Android because it re implements some core Java files.

said
  • 474
  • 4
  • 8
  • 18