【问题标题】:Why is ProGuard suddenly unable to compile my application?为什么 ProGuard 突然无法编译我的应用程序?
【发布时间】:2013-07-01 07:20:59
【问题描述】:

自最初发布以来,我一直在使用 Android Studio,没有任何 ProGuard 问题。今天突然停止工作了。据我所知,任何会干扰 Proguard 的文件都没有改变。例如,我的 ProGuard 配置文件保持不变,并且自上次成功构建以来,ActionBarSherlock(现在遇到错误的模块之一)没有以任何方式更改。

错误日志建议使用-dontskipnonpubliclibraryclassmembers,但这并不能解决问题。使用包含的默认配置而不是我自己的默认配置运行 ProGuard 仍然会导致相同的错误。

据我所知,当 Android Studio 构建我的应用程序时,模块现在正在从应用程序中剥离。我不确定它是否只是没有将适当的标志传递给 ProGuard,或者 Proguard 是否会自行删除它们。

一些相关日志:

ProGuard: [Meditation Assistant] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced field 'android.content.Context mContext' in class com.actionbarsherlock.widget.SuggestionsAdapter
ProGuard: [Meditation Assistant] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced method 'android.database.Cursor getCursor()' in class com.actionbarsherlock.widget.SuggestionsAdapter
ProGuard: [Meditation Assistant] Warning: com.actionbarsherlock.widget.SuggestionsAdapter: can't find referenced field 'android.database.Cursor mCursor' in class com.actionbarsherlock.widget.SuggestionsAdapter
--snip--
ProGuard: [Meditation Assistant]       You should check if you need to specify additional program jars.
ProGuard: [Meditation Assistant] Warning: there were 10 unresolved references to classes or interfaces.
ProGuard: [Meditation Assistant]          You may need to specify additional library jars (using '-libraryjars').
ProGuard: [Meditation Assistant] Warning: there were 191 unresolved references to program class members.

【问题讨论】:

    标签: android proguard


    【解决方案1】:

    消息

    Warning: there were 10 unresolved references to classes or interfaces.
    

    建议 ProGuard 找不到一些需要的类。这些类在 ProGuard 早期的控制台输出中列出。您应该检查所有必要的 jar 是否都在目录“libs”中。在这种情况下,android-support-v4.jar 可能会丢失。

    【讨论】:

      【解决方案2】:

      我在 proguard-project.txt 中添加以下行来解决它:

      -libraryjars libs/android-support-v4.jar
      

      如果使用 Eclipse,请不要忘记在导出 APK 之前清理项目。

      【讨论】:

      • Ant/Eclipse/Gradle 构建应该已经自动将库中的所有 jar 传递给 ProGuard。您永远不需要自己指定 -injars/-outjars/-libraryjars。您可以通过查看其控制台输出(例如使用“gradle --info”)来检查 ProGuard 读取的 jar 列表。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多