Reputation: 11211
I made a mail client with the use of javamail api for android and the app runs well in emulator or device... Now I want to export the project using eclipse but I got the following errors:
Warning: org.apache.harmony.awt.datatransfer.DataProxy: can't find superclass or interface java.awt.datatransfer.Transferable
Warning: org.apache.harmony.awt.datatransfer.NativeClipboard: can't find superclass or interface java.awt.datatransfer.Clipboard
Warning: javax.activation.CommandInfo: can't find referenced class java.beans.Beans
Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.Sasl
Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslClient
Warning: com.sun.mail.imap.protocol.IMAPSaslAuthenticator: can't find referenced class javax.security.sasl.SaslException
Warning: org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.Point
Warning: org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceContext
Warning: org.apache.harmony.awt.datatransfer.DragSourceEventProxy: can't find referenced class java.awt.dnd.DragSourceEvent
As I can see the javamail api uses java.awt and javax.security libs... how can I add them in my project so I can export my project and obfuscate it?
Thank you very much!
UPDATE:
I tried to import the jre library in my project and those errors are gone but new ones apeared:
Proguard returned with error code 1. See console
Note: there were 4243 duplicate class definitions.
Warning: library class com.sun.xml.internal.messaging.saaj.soap.FastInfosetDataContentHandler extends or implements program class javax.activation.DataContentHandler
Warning: library class com.sun.xml.internal.ws.encoding.XmlDataContentHandler extends or implements program class javax.activation.DataContentHandler
Warning: library class com.sun.xml.internal.messaging.saaj.soap.MessageImpl$1 extends or implements program class javax.activation.DataSource
Warning: library class com.sun.xml.internal.ws.encoding.StringDataContentHandler extends or implements program class javax.activation.DataContentHandler
What can I do?
Upvotes: 5
Views: 8661
Reputation: 45648
The listed java classes are not part of the Android runtime. The cleanest solution would be to remove the classes that reference them from the javamail library, because they can never work in this environment.
In general, you could also filter them out in your ProGuard configuration, but the Android build script doesn't support filters.
As a simple alternative, you can suppress the warnings:
-dontwarn java.awt.**,javax.security.**,java.beans.**
ProGuard will then proceed without complaining.
Upvotes: 11
Reputation: 11211
I have solved the problem by adding the jre library in the project and ten adding this comand to proguard.cfg file:
-libraryjars <java.home>/lib/rt.jar(java/**,javax/security/**,javax/activation/**)
hope this help somebody :P
Upvotes: 4