Unable to convert classes into dex format Unity

Some Background

When Unity builds your project for Android, it invokes several tools from the Android SDK. As part of that process, it converts all of your native (Java) code for Android into a file format called DEX (Dalvik executable).

All of your Android plugins get built up into a single package using that tool. The problems start when a few plugins have the same compiled Java code (classes) in them. This will cause the DEX tool to fail with an error like the one you’re seeing:

Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzbyb; Uncaught translation error: java.lang.IllegalArgumentException: already added: Lcom/google/android/gms/internal/zzbyc;

This means that classes with those names were already included in another library, and so they cannot be added again.

Possible Causes

As explained above, this error occurs when you have duplicate plugins in your project; this can happen in different scenarios, here are some examples:

  • The same plugin is included more than once, under different folders of the project.
  • The same plugin is included more than once with different versions.
  • A plugin contains other dependencies “embedded” inside it, but these dependencies are already included in the project in some form.

How To Fix

You should look up duplicate Android plugins in your project and eliminate them (keep only 1 copy). From the error message you posted, the issue here is related to Google play services libraries. You should look into that (libraries named play-services-xxxx.aar).

Paid Help (Shameless Plug)

I provide a professional service for fixing this exact kind of issue. In case you (or anyone else) are not able to resolve such an issue themselves, feel free to contact me and get it solved.

Leave a Comment