android proguard, skip jars

荒凉一梦 提交于 2019-12-06 09:13:21

问题


I want to know if it is possible to skip jars in proguard so that it don't obfuscate them... I am trying to do that with this comand: -libraryjars myjar.jar but I keep having problems with my code..

I am trying to export a project that has javamail api for android and the project is supposed to retreive my exchange emails using imaps protocol...

I am using a trust manager to pass the certificate validation (because I have self signed certificate on my exc server). If I compile and run the app without exporting it, everything works fine. If I export the app I am getting the invalid certificate error.

In my activity I pass the SSLSocketFactory (the one that skips the cert validation) on a Property object :

props.setProperty("mail.store.protocol", "imaps");
props.setProperty("mail.imaps.socketFactory.class", "mail.utils.DummySSLSocketFactory");  

So I think the problem could be somewhere in the javamail jar but I don't know how to let all classes from the jar to be skipped by proguard...


回答1:


In a general ProGuard configuration, specifying -libraryjars would be the preferred solution indeed.

In the Android build script, jars in the libs directory are already added automatically as -injars, which makes this less convenient. You can still specify to preserve all code though, e.g. all public classes, fields, and methods in the library:

-keep public class mail.** {
  public *;
}

You may be able to refine the configuration by only keeping relevant classes, e.g.

-keep class mail.imaps.socketFactory
-keep class mail.utils.DummySSLSocketFactory
...

Without knowing the internal implementation of the library, this refinement will probably require some experimentation.



来源:https://stackoverflow.com/questions/5411164/android-proguard-skip-jars

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