[Android] ProGuard Error: Proguard returned with error code 1

Recent days, I met a problem about the Proguard on the Android application. When I want to release the signed APK, the Eclipse feedback the error message that is like the following example,

org.eclipse.core.runtime.CoreException: Proguard returned with error code 1. See console

at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:280)

at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.doExport(ExportWizard.java:296)

at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard.access$0(ExportWizard.java:233)

at com.android.ide.eclipse.adt.internal.wizards.export.ExportWizard$1.run(ExportWizard.java:218)

at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

Caused by: Proguard Error 1

Output:

Note: there were 201 duplicate class definitions.

Warning: com.company.xxx.ui.ccc: can't find superclass or interface com.company.xxx.ui.bbbb$Listener

Warning: com.company.xxx.ui.abcde: can't find referenced class com.company.xxx.aaaa.InterfaceAAA

...

...

...


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

You may need to specify additional library jars (using '-libraryjars').

Error: Please correct the above warnings first.
at com.android.ide.eclipse.adt.internal.build.BuildHelper.runProguard(BuildHelper.java:571)
at com.android.ide.eclipse.adt.internal.project.ExportHelper.exportReleaseApk(ExportHelper.java:244)
... 4 more

Because the application includes the 3rd-party jar library, I think this may be just the library-reference problem.
So, at the first, I followed the explanation of the error and tried to add the “-libraryjars” in the proguard-project.txt, but I didn’t obtain the right result. Therefore, I searched the error message on the Google, but I didn’t get any useful information.
So sad! I read the manual in the ProGuard website. In the manual, the section Shrink and Optimization give the hint. I think Shrink and Optimization may occur the error, so I added the “-dontshrink” and “-dontoptimize” parameters in the proguard-project.txt. Unfortunately, I got the error again!

By the way, sometimes, I could get the final APK, but the APK is missing some classes (definitely, almost all the classes is missed). Sometimes, I could get correct final APK. It’s so dangerous, if I don’t test the final APK fully. I perhaps have the errors after publishing the application.

Finally, I found out some developers discuss the AdMob jar library should be added into the “/libs” in the project. Therefore, I think this may could apply for my condition. In the Android project, I copy the 3rd-party jar library into the /libs directory in the project, and then I change the Libraries Build Path to the “/libs” directory. Then, I succeed in building the released APK correctly and it is not missing any classes now. Happy!

One comment

  1. I was struck for like a hour. you solved it. Thanks a lot

發佈留言