I was tasked with making an Android build of a project I worked on.  During the ‘Repackaging Resources’ step, a dialog box appeared with an error message:
“CommandInvokationFailure: Failed to re-package resources. See the Console for details.”
In the console were two errors, which were identical except one had a Unity error prefix at the beginning.


Most of the message was incomprehensible to me, but a few lines stood out as maybe something I could fix.

I figured that those values were defined more than once, which is a simple enough problem to understand. So I checked out the file that the errors were pointing to. Nothing looked strange so I figured that the values were defined somewhere else, and I commented out the lines defining those values to see if that fixed the error.

The error persisted, so I looked around online for answers. There were plenty of forums and Q&A sites with people asking about the same error message, but most went unsolved and I didn’t find any that I was sure were caused by the same issue.  Turns out I was seeing a generic error message that could be caused by many different problems.

I found a couple of threads talking about adding the “google-play-services_lib” folder from the Android SDK to the project.  That folder was already in the project, but I decided to re-copy it in order to update it.  This didn’t fix the problem, but seeing the folders around it made me think that it might not be necessary.  We have a plugin in our project called ‘Cross Platform Native Plugins – Ultra Pack” made by a company called VoxelBusters.  It manages platform specific features such as in app purchasing, as well as social elements like iOS’s GameCenter and the Android equivalent.  That plugin included folders and files for android that seemed to fill the same purpose.  Thinking that might mean the “google-play-services_lib” was unnecessary, I decided to remove it from the project, since I could always add it right back in if any problems came up.

Removing that folder got me past the repackaging step, but the build still ran into errors on a later portion of the build process.  Again a dialog box appeared popped up, this time with the message:

CommandInvokationFailure: Unable to convert classes into dex format.

Unity got farther in the build process, so I assumed progress had been made.  Unfortunately I had no idea what this new error meant, or what to do about it, so I turned to the internet.

Again, there were plenty of people asking for help with the same error message, but the details of the error were varied and solutions were rare.  So I figured I just try whatever solutions I could find.  There were a few potential fixes I tried that I can’t remember, but I do know that I checked the project for duplicate jar files and eventually reimported all my assets, which worked for a few people.  Not for me though, and the error persisted.

I knew that the Cross Platform Native Plugins plugin was up to date, but I downloaded and imported a fresh copy just to make sure everything was correct.  Doing so ended up adding the “google-play-services_lib” folder back into the project.  Apparently it was needed even with the plugin.  This brought me back to the original error from the re-packaging step.  More research on the web suggested that the Java JDK might need to be reinstalled and that the JAVA_HOME and PATH user variables set to the JDK directory.  After that fix failed, I decided to call over John McGlothan, our senior programmer, over to see if he could identify a solution.  Unfortunately a solution still evaded us, but he did find that the attributes listed in the error showed up only in the one file when a text search was done for them.  This was very confusing, how could an attribute be already defined when there’s only one place that defines it?

John had to return to his own tasks, so I continued trying to find new angles with which to search the internet for answers. At some point I noticed that the version of the Android API I had installed was not listed as an option for the minimum API version in Unity’s player settings.  Using the Android SDK Manager, I installed Android 5.1 (API 22), and set the minimum API in the player settings to the same.  While API 22 is the second newest one, I figured that if that worked, I could try lowering the API number afterwards.  I restarted Unity to make sure that the new additions were loaded and recognized, but nothing changed.  Thinking maybe there was still some piece of the API that I needed, I selected the entire extras folder in the SDK Manager and told it to install.  When that was finished, I restarted Unity again, only to find that the problem was still unfixed.

At that point it was getting late, and I was out of ideas.  I didn’t like going home without fixing the problem, but I hoped that the next day would provide a fresh perspective that led to an answer.  In the end I was told that making an Android build wasn’t worth the time it was taking, and was given another task.  Later that day we tried to make a build on another computer, but the error was there too.  As of this writing I still don’t know of a solution, but if anyone knows what it is, I’d be happy to know.

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment