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?
Obfuscation: shortens the name of classes and members, which results in reduced DEX file sizes.
To debug Proguard/R8 configuration, navigate to app\build\outputs\mapping\release. There we can see the following files: configuration. txt – merged file with all configurations – from the app, default Android, AAPT, all the libraries, etc.
enableR8 setting itself is deprecated, causing these deprecation warnings. If you have android. enableR8 = false to use proguard for optimiation and obfuscation, consider migrating to R8 instead.
In order to obfuscate your library what you need to do is: Make sure gradle settings for lib module state minifyEnabled true . run ./gradlew assemble{flavor}Release.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With