使用 Proguard 通过 Dropbox.com 库混淆 Android 应用程序

发布于 2024-12-13 18:01:45 字数 1713 浏览 0 评论 0原文

我刚刚创建了一个需要 Dropbox.com API 库的 Android 应用程序。我现在尝试在“发布”模式下构建应用程序,并希望在代码上运行混淆器以对其进行混淆。然而,每当我尝试运行 Proguard 时,我都会收到以下错误:

Proguard returned with error code 1. See console
Warning: com.dropbox.client2.DropboxAPI: can't find referenced class org.json.simple.JSONArray
Warning: com.dropbox.client2.DropboxAPI: can't find referenced class org.json.simple.JSONArray
Warning: com.dropbox.client2.DropboxAPI$Entry: can't find referenced class org.json.simple.JSONArray
Warning: com.dropbox.client2.DropboxAPI$Entry: can't find referenced class org.json.simple.JSONArray
Warning: com.dropbox.client2.RESTUtility: can't find referenced class org.json.simple.parser.JSONParser
Warning: com.dropbox.client2.RESTUtility: can't find referenced class org.json.simple.parser.JSONParser
Warning: com.dropbox.client2.RESTUtility: can't find referenced class org.json.simple.parser.JSONParser
Warning: com.dropbox.client2.RESTUtility: can't find referenced class org.json.simple.parser.ParseException
Warning: there were 8 unresolved references to classes or interfaces.
         You may need to specify additional library jars (using '-libraryjars'),
         or perhaps the '-dontskipnonpubliclibraryclasses' option.
         java.io.IOException: Please correct the above warnings first.
         at proguard.Initializer.execute(Initializer.java:308)
         at proguard.ProGuard.initialize(ProGuard.java:210)
         at proguard.ProGuard.execute(ProGuard.java:85)
         at proguard.ProGuard.main(ProGuard.java:499)

我已经包含了 '-dontskipnonpubliclibraryclasses' 选项,但这对我没有任何帮助。我尝试包含“-libraryjars”选项,但我可能错误地使用了它,因为我不太确定我打算如何使用该标志。

有谁知道我如何纠正这个错误?现在,我无法在通过 Proguard 运行应用程序时构建它。任何帮助表示赞赏!谢谢!

I've just finished creating an Android app that requires the Dropbox.com API libraries. I'm now trying to build the application in 'Release' mode and would like to run proguard on the code in order to obfuscate it. However, whenever I attempt to run Proguard, I get the following error:

Proguard returned with error code 1. See console
Warning: com.dropbox.client2.DropboxAPI: can't find referenced class org.json.simple.JSONArray
Warning: com.dropbox.client2.DropboxAPI: can't find referenced class org.json.simple.JSONArray
Warning: com.dropbox.client2.DropboxAPI$Entry: can't find referenced class org.json.simple.JSONArray
Warning: com.dropbox.client2.DropboxAPI$Entry: can't find referenced class org.json.simple.JSONArray
Warning: com.dropbox.client2.RESTUtility: can't find referenced class org.json.simple.parser.JSONParser
Warning: com.dropbox.client2.RESTUtility: can't find referenced class org.json.simple.parser.JSONParser
Warning: com.dropbox.client2.RESTUtility: can't find referenced class org.json.simple.parser.JSONParser
Warning: com.dropbox.client2.RESTUtility: can't find referenced class org.json.simple.parser.ParseException
Warning: there were 8 unresolved references to classes or interfaces.
         You may need to specify additional library jars (using '-libraryjars'),
         or perhaps the '-dontskipnonpubliclibraryclasses' option.
         java.io.IOException: Please correct the above warnings first.
         at proguard.Initializer.execute(Initializer.java:308)
         at proguard.ProGuard.initialize(ProGuard.java:210)
         at proguard.ProGuard.execute(ProGuard.java:85)
         at proguard.ProGuard.main(ProGuard.java:499)

I'm already including the '-dontskipnonpubliclibraryclasses' option and that's not helping me at all. I tried including the '-libraryjars' option, though, I may have been using it incorrectly as I'm not really sure how I'm intended to use that flag.

Does anyone have any ideas how I can correct this error? Right now, I'm unable to build my application while running it through Proguard. Any help is appreciated! Thanks!

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

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

发布评论

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

评论(2

樱花坊 2024-12-20 18:01:45

比照。 ProGuard 手册 >故障排除>>警告:找不到引用的类

com.dropbox 似乎依赖于 org.json。理论上,您应该将 org.json jar 添加到您的 libs 目录中,以便它可以被处理并包含在您的应用程序中。实际上,您的应用程序在没有它的情况下也可以正常工作,因此您可以让 ProGuard 忽略缺少的依赖项:

-dontwarn org.json.**

或者

-dontwarn com.dropbox.**

您不应该添加 -libraryjars,因为您指定的任何 jar 都不会出现在 Android 设备上,除非您设法设法安装它们。

Cfr. ProGuard manual > Troubleshooting > Warning: can't find referenced class

com.dropbox seems to depend on org.json. In theory, you should therefore add the org.json jar to your libs directory, so it can be processed and included in your application. In practice, your application works fine without it, so you can let ProGuard ignore the missing dependency:

-dontwarn org.json.**

or

-dontwarn com.dropbox.**

You shouldn't add -libraryjars, because any jars that you specify won't be present on Android devices unless you'd somehow manage to install them.

慢慢从新开始 2024-12-20 18:01:45

好吧,通过基本上的反复试验,我至少找到了一个解决方法。我不认为这本身就是一个实际的“答案”,但是,通过将以下几行添加到我的 proguard.cfg 文件中,我的问题得到了解决。

-libraryjars /lib/dropbox-android-sdk-1.2.1.jar
-libraryjars /lib/httpmime-4.0.3.jar
-libraryjars /lib/json_simple-1.1.jar

-dontwarn com.dropbox.client2.DropboxAPI
-dontwarn com.dropbox.client2.DropboxAPI$Entry
-dontwarn com.dropbox.client2.RESTUtility

希望这能帮助那些将来遇到这个问题或类似问题的人。

Well, through trial-and-error basically, I at least got a workaround going. I wouldn't consider this an actual 'answer' per se, however, my problem was solved by adding the following lines to my proguard.cfg file.

-libraryjars /lib/dropbox-android-sdk-1.2.1.jar
-libraryjars /lib/httpmime-4.0.3.jar
-libraryjars /lib/json_simple-1.1.jar

-dontwarn com.dropbox.client2.DropboxAPI
-dontwarn com.dropbox.client2.DropboxAPI$Entry
-dontwarn com.dropbox.client2.RESTUtility

Hopefully that'll help someone who finds themselves stuck with this or a very similar problem in the future.

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