Over a million developers have joined DZone.

My Reminder: How to fix "conversion to Dalvik format failed with error code 1"

· Java Zone

Bitbucket is for the code that takes us to Mars, decodes the human genome, or drives your next car. What will your code do? Get started with Bitbucket today, it's free.

Every month or so, while exporting an Android application to get an apk file, I see the mysterious message: “Conversion to Dalvik format failed with error code 1″. Information on what to do is easy to come by. I search Google on that phrase and get to another great StackOverflow page with an explanation.

http://stackoverflow.com/questions/2680827/conversion-to-dalvik-format-failed-with-error-1-on-external-jar

export-app-error-code-1The problem for me is that particular question /answer post is fairly long and points out that there  are several different things you should try. Since I keep forgetting which of those work for me, I am posting ny standard steps for myself here.

I work on a Macbook, run Eclipse, and I usually do very well at keeping my Android environment up-to-date. Also, when I build I have Proguard set to run, which means I will see some unusual messages from time to time. Those tend to throw me off and forget what I should be doing.

My Standard Fixes

  1. I start with doing a clean build of the project with “Project – Clean”. I include the project and any projects it depends on.
  2. Then I check to see which Proguard I have installed. A new Proguard is required. Right now that is 4.11.

Step 1 used to be all I needed to do. I’d do the “clean” build and then try to export again, and it would work. This last week, however, that did not help. The export would fail and the Console messages would indicate that Proguard was having trouble. There are, of course, lots of things that Proguard can report on, but these messages said that none of the classes of the app itself  could be found. That did not make sense to me since I had built apk files for the very same app not long before. So that’s when the closer reading of the StackOverflow message paid off.  Someone noted that a newer Proguard fixed the problem for them.

Android tool set for Eclipse has an old version of Proguard. One more thing to watch out for is that the Android tools in Eclipse have an old version of Proguard. Any time you update that part of your Eclipse installation, it is going to overwrite the new Proguard you installed with one that might not work. So that’s why I have two steps. Fixing the problem with Step 2 is something I have to keep doing until the newer Proguard is in the Android tools update. The Proguard folder is inside folder “android\sdk\tools”.

So good advice, as always, from StackOverflow provides a solution. And for me, a good reminder is what I need so here it is in an easy place for me to find it.

Bitbucket is the Git solution for professional teams who code with a purpose, not just as a hobby. Get started today, it's free.

Topics:

Published at DZone with permission of Bill Lahti. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}