【问题标题】:Using Proguard to Obfuscate Android App with Dropbox.com Libraries使用 Proguard 对带有 Dropbox.com 库的 Android 应用程序进行混淆
【发布时间】:2011-11-08 07:38:57
【问题描述】:

我刚刚创建了一个需要 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 运行我的应用程序时构建它。任何帮助表示赞赏!谢谢!

【问题讨论】:

标签: java android dropbox proguard dropbox-api


【解决方案1】:

参照。 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 设备上,除非您设法安装它们。

【讨论】:

    【解决方案2】:

    嗯,基本上通过反复试验,我至少找到了一种解决方法。我不会认为这本身就是一个实际的“答案”,但是,通过将以下行添加到我的 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
    

    希望这将帮助那些发现自己在未来遇到此问题或非常类似问题的人。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-11-22
      • 2011-09-26
      • 1970-01-01
      • 1970-01-01
      • 2011-04-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多