I have some java code that works well in java but doesn't work at all in android. I have turned this code into a simple library that I thought I included all it's dependencies in the jar. However when run in android it tries to use the default android dependencies that came with the android project. I can't use an emulator because I am working with preexisting code and I just need this specific library to use the java versions of libraries. Is there a way where I can package this to include the default java libraries into the jar so that it only uses the java libraries and nothing from android?
Here is the code so far, there may be bugs in code as I have been modifying it to work as a library but the original code did work as a jar file that sent an email every time you ran the application.
public class Main {
public static void main(String User, String Pass, String host) {
System.out.println("Starting");
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
ExchangeCredentials credentials = new WebCredentials(User, Pass);
service.setCredentials(credentials);
try {
String ewshost = (host);
service.setUrl(new java.net.URI(ewshost));
EmailMessage msg= new EmailMessage(service);
msg.setSubject("Hello world!");
msg.setBody(MessageBody.getMessageBodyFromText("Sent using the EWS Java API."));
msg.getToRecipients().add(User);
msg.send();
System.out.println("Finished");
} catch (Exception e) {
e.printStackTrace();
}
}
}
Update: When I tried to compile this with it's prerequisite classes extracted and included in the jar this is the output I received when I tried to use my library in android.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.commons.logging.impl.WeakHashtable$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
Given what I can tell from fiddling around this is because the dependencies of the library I have created is conflicting with the default libraries. So I still need to somehow make it so that this library's dependencies are not seen at the top level and are strictly used just for the library.