Proguard removes com.sun.mail.imap.IMAPProvider

陌路散爱 提交于 2021-02-11 14:49:14

问题


In my app I send emails to some specific address, it all works fine, but when it comes to obfuscation, shrinking, etc with ProGuard it fails

I've tried adding some ProGuard rules, which didn't work

That's my ProGuard

-keepclassmembernames class com.sun.mail.imap
2019-08-08 14:29:26.811 11724-12675/? E/AndroidRuntime: FATAL EXCEPTION: AsyncTask #5
    Process: com.redegrow.besttaxi, PID: 11724
    java.lang.RuntimeException: An error occurred while executing doInBackground()
        at android.os.AsyncTask$3.done(AsyncTask.java:354)
        ...
     Caused by: java.util.ServiceConfigurationError: e.b.r: Provider com.sun.mail.imap.IMAPProvider not found
        at java.util.ServiceLoader.fail(ServiceLoader.java:233)
        at java.util.ServiceLoader.access$100(ServiceLoader.java:183)
        at java.util.ServiceLoader$LazyIterator.nextService(ServiceLoader.java:373)
        at java.util.ServiceLoader$LazyIterator.next(ServiceLoader.java:416)
        at java.util.ServiceLoader$1.next(ServiceLoader.java:494)
     ...
     Caused by: java.lang.ClassNotFoundException: com.sun.mail.imap.IMAPProvider
     ...
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.sun.mail.imap.IMAPProvider" on path: DexPathList[[zip file "/data/app/com.redegrow.besttaxi-_Kl-yVNRgbmmwzLXuKKmWQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.redegrow.besttaxi-_Kl-yVNRgbmmwzLXuKKmWQ==/lib/arm64, /system/lib64, /vendor/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
       ...

回答1:


Well, I found the solution. It's not great, but at least it works

-keep class com.sun.mail.imap.IMAPProvider
-keep class com.sun.mail.imap.IMAPSSLProvider
-keep class com.sun.mail.smtp.** {*;}



回答2:


Using keepclassmembernames for a class tells ProGuard not to obfuscate the class members, but does not have an effect on the class itself. So ProGuard does its job and changes the class name.

So if you want to prevent ProGuard from obfuscating the class name you should use keepnames instead.

To prevent both the obfuscation and shrinking (which is removing in case of not being used), you should use keepclassmembers if you want to target only the class members and keep to target the class itself and its members.



来源:https://stackoverflow.com/questions/57409930/proguard-removes-com-sun-mail-imap-imapprovider

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!