android proguard,跳过罐子 [英] android proguard, skip jars

查看:77
本文介绍了android proguard,跳过罐子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有可能在proguard中跳过jar,以免混淆它们...我正在尝试使用以下命令:-libraryjars myjar.jar但我的代码始终存在问题..

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..

我正在尝试导出一个具有适用于Android的javamail api的项目,并且该项目应该使用imaps协议检索我的交换电子邮件...

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...

我正在使用信任管理器来通过证书验证(因为我的exc服务器上有自签名证书).如果我在不导出的情况下编译并运行该应用程序,则一切正常.如果我导出应用程序,则会收到无效的证书错误.

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.

在我的活动中,我在Property对象上传递了SSLSocketFactory(跳过证书验证的那个):

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");  

所以我认为问题可能出在javamail jar中,但是我不知道如何让proguard跳过jar中的所有类...

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...

推荐答案

在常规的ProGuard配置中,指定-libraryjars确实是首选解决方案.

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

在Android构建脚本中,已经自动将libs目录中的jars添加为-injars,这使此操作不太方便.您仍然可以指定保留所有代码,例如库中的所有公共类,字段和方法:

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.

这篇关于android proguard,跳过罐子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆