Monday, May 9, 2011

Proguard and the Android Compatibility Library

I am just about finished with my current Android app, and have been working on the release process. This morning I ran into the following problem when I enabled Proguard and tried to Export a release version in Eclipse:

eclipse.buildId=M20110210-1200
java.version=1.6.0_25
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product -clean


Error
Mon May 09 13:25:56 PDT 2011
Export Wizard Error

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:250)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.doExport(ExportWizard.java:290)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.access$0(ExportWizard.java:229)
at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard$1.run(ExportWizard.java:214)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
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:596)
at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:204)
... 4 more


My app is built around the Fragments API so I use the android-support-v4.jar library for compatibility with pre-honeycomb devices. After a lot of searching, I determined that proguard was doing something to this library that was making the the Dalvik compiler unhappy. I was finally able to build the release version after adding the following lines to proguard.cfg:

-dontwarn **CompatHoneycomb
-keep class android.support.v4.** {
*;
}

No comments:

Post a Comment