-optimizationpasses高于2时的Proguard错误

时间:2016-02-25 06:47:40

标签: android eclipse optimization proguard

修改

这是由旧的Proguard版本(4.7)引起的。用5.2

不再发生

我使用Proguard(在eclipse中)来优化和混淆我的Android项目,但发生了一些奇怪的事情。当我将 -optimizationpasses 设置为1或2时,它可以,但是当我设置为3或更高时,我收到此错误

  

转换为Dalvik格式失败,错误1

在Eclipse的错误日志视图中,我发现条目&转换为Dalvik格式失败,错误1':它包含此堆栈跟踪

org.eclipse.core.runtime.CoreException: Conversion to Dalvik format failed with error 1
    at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:317)
    at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.doExport(ExportWizard.java:313)
    at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.access$0(ExportWizard.java:238)
    at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard$1.run(ExportWizard.java:223)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
Caused by: com.android.ide.eclipse.adt.internal.build.DexException: Conversion to Dalvik format failed with error 1
    at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:825)
    at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:274)
    at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.doExport(ExportWizard.java:313)
    at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.access$0(ExportWizard.java:238)
    at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard$1.run(ExportWizard.java:223)
    at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)

以下是有关优化的Proguard配置摘录:

-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
#-optimizationpasses 3 or above -> exception
-optimizationpasses 2
#-allowaccessmodification
-dontpreverify

问题:

  • 当-optimizationpasses高于此值时,为什么Proguard会导致错误 2? (特别是因为android默认设置是5(在sdk 23 / M中)
  • 如何/在哪里可以找到有关此根本原因的更多详细信息 问题,并可能向Proguard团队报告错误?

感谢您的帮助

1 个答案:

答案 0 :(得分:1)

请更新至Proguard的最新版本,即4.7至5.2

这应解决问题。