我刚刚创建了一个需要 Dropbox.com API 库的 Android 应用程序。我现在正尝试在“发布”模式下构建应用程序,并希望在代码上运行 proguard 以混淆它。但是,每当我尝试运行 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 运行我的应用程序时构建它。任何帮助表示赞赏!谢谢!
最佳答案
比较。 ProGuard manual > Troubleshooting > Warning: can't find referenced class
com.dropbox 似乎依赖于 org.json。理论上,您应该因此将 org.json jar 添加到您的 libs 目录,以便它可以被处理并包含在您的应用程序中。实际上,您的应用程序在没有它的情况下也能正常工作,因此您可以让 ProGuard 忽略缺少的依赖项:
-dontwarn org.json.**
或
-dontwarn com.dropbox.**
您不应该添加 -libraryjars,因为您指定的任何 jar 都不会出现在 Android 设备上,除非您设法安装它们。
关于java - 使用 Proguard 混淆 Android 应用程序与 Dropbox.com 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8030532/