Android ADT、Proguard 和外部 Jars 的问题

发布于 2024-10-14 04:58:13 字数 675 浏览 11 评论 0原文

因此,我试图让 ADT 的内置 proguard 实现适用于我的应用程序。不幸的是,它似乎被我引用的第三方库中的各种类所困扰。 我已经尝试过各种(如果不是全部)我能想到的 -libraryjars 和 -keep 公共类行的组合,但这一切都没有好处。我对 Proguard 没有那么丰富的经验,所以说实话,我不知道我哪里出了问题。我试过谷歌,但大部分信息都与 Ant 脚本有关。

我尝试过的一些事情:

  • 文件顶部或底部的 -libraryjars C:\Users\Dave\workspace\Dropbox_Sync_for_Tasker_and_Locale\lib\apache-mime4j-0.6.jar 等行

  • 尝试创建类似这样的 jar 路径的行,但根本没有成功。

  • 类似 -keep public class org.apache.commons.logging.LogFactory 的行

  • 引用错误其他部分的行行,如 -keep public class org.apache.james.mime4j.field.MailboxListField

不管怎样,错误日志是一堵巨大的文本墙,所以我把它放在粘贴箱这里上。

So, I'm trying to get the ADT's built-in proguard implementation working for my app. Unfortunately, it seems to be choking on various classes in third-party libraries I references.
I've tried various, if not all, the combinations of -libraryjars and -keep public class lines I can think of, but it's all to no good. I'm not that experienced with Proguard, so honestly, I don't know where I'm going wrong. I've tried google, but most of the information relates to Ant scripts.

Some of the things I've tried:

  • Lines like -libraryjars C:\Users\Dave\workspace\Dropbox_Sync_for_Tasker_and_Locale\lib\apache-mime4j-0.6.jar at the top or bottom of the file

  • Lines attempting to make paths to jars like that relatively, to no success at all.

  • Lines like -keep public class org.apache.commons.logging.LogFactory

  • Line that refer to the other part of the error lines, like -keep public class org.apache.james.mime4j.field.MailboxListField

Anyway, the error log is a huge wall of text, so I've put it on a pastebin here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

又爬满兰若 2024-10-21 04:58:13

所以,如果你碰巧找到了这个答案,并且觉得,嗯,我也有这个问题,我希望他发布了他的解决方案,那么你就幸运了一半。

我修复它的方法是将 -libraryjars 行粘贴在那里,然后

-dontwarn org.apache.commons.logging.LogFactory
-dontwarn net.jcip.annotations.NotThreadSafe
-dontwarn net.jcip.annotations.ThreadSafe
-dontwarn net.jcip.annotations.Immutable

它工作得很好。这是一个黑客,而且很脏,但它为我解决了这个问题。不幸的是,如果您也遇到此问题,那么您仍然只能靠自己。

So, if you happen to find this answer, and are like, hm, I have that problem too, I wish he posted his solution, you're half in luck.

The way I fixed it was to just stick the -libraryjars lines in there, and then

-dontwarn org.apache.commons.logging.LogFactory
-dontwarn net.jcip.annotations.NotThreadSafe
-dontwarn net.jcip.annotations.ThreadSafe
-dontwarn net.jcip.annotations.Immutable

And it worked fine. It's a hack, and it's dirty, but it solved it for me. Unfortunately, you're still on your own if you too have this problem.

尐籹人 2024-10-21 04:58:13

在将“apache-mime4j-0.6.1.jar”和“httpmime-4.0.1.jar”添加到我的项目后,我遇到了完全相同同样的问题。 (用于将二进制数据多部分 POST'ing 到我的服务器)。

我也不熟悉 pro-guard,但至少我已经设法将我的自定义小部件添加到 proguard.cfg 中 - 不幸的是,事实证明 apache 库更难添加!

这是我的修复...我已将此添加到 proguard.cfg 的底部:

#APACHE LIBRARY
-libraryjars /libs/apache-mime4j-0.6.1.jar
-libraryjars /libs/httpmime-4.0.1.jar
-keepnames class org.apache.** {*;}
-keep public class org.apache.** {*;}
-dontwarn org.apache.commons.logging.LogFactory
-dontwarn org.apache.http.annotation.ThreadSafe
-dontwarn org.apache.http.annotation.Immutable
-dontwarn org.apache.http.annotation.NotThreadSafe

我希望前 4 行将是修复。不幸的是,需要 dontwarn 来真正“修复”它。

如果我错了,请纠正我(因为我不是 proGuard 专业人士),但我相信前 4 行确保按原样使用库。四行的第二部分(不要警告)只是掩盖了剩余的废话,并且没有纠正一些潜在的问题。
我不知道根本问题是什么。

I had exactly the same problem after adding "apache-mime4j-0.6.1.jar" and "httpmime-4.0.1.jar" to my project. (for multipart POST'ing of binary data to my server).

I am also not familiar with pro-guard but at least I've managed to add my custom widget to the proguard.cfg - unfortunately the apache library proved even more difficult to add !

this is my fix... I have this added to the bottom of proguard.cfg :

#APACHE LIBRARY
-libraryjars /libs/apache-mime4j-0.6.1.jar
-libraryjars /libs/httpmime-4.0.1.jar
-keepnames class org.apache.** {*;}
-keep public class org.apache.** {*;}
-dontwarn org.apache.commons.logging.LogFactory
-dontwarn org.apache.http.annotation.ThreadSafe
-dontwarn org.apache.http.annotation.Immutable
-dontwarn org.apache.http.annotation.NotThreadSafe

I was hoping that the first 4 lines would be the fix. Unfortunately the dontwarn's are needed to really "fix" it.

Correct me if I am wrong (since I'm no proGuard pro), but I believe the first 4 lines make sure that the libraries are used as-is. The second section of four lines (dontwarn) just cover up the remaining crap and don't correct some underlying issue.
What the underlying issue is I don't know.

不交电费瞎发啥光 2024-10-21 04:58:13

尝试下载 commons-logging.jar,将其放入您的库中并添加 -libraryjars 到你的 proguard 配置。

try downloading the commons-logging.jar, put it in your libs and add a -libraryjars to your proguard config.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文