CommandInvokationFailure: Unable to convert classes into dex format.
Greetings,
I realize that this is a fairly common error, and that there are many threads dedicated to debugging it. I have been through most, if not all of the relevant ones searching for a solution - but have been unable to figure out a workaround.
Here's the important part of the error I'm getting from what I've gathered:
trouble writing output: Too many field references to fit in one dex file: 68927; max is 65536.
You may try using multi-dex. If multi-dex is enabled then the list of classes for the main dex list is too large.
From the threads that I've read, this means that there are too many field references in my project - which is caused by having 'too many .jar files.'
The possible solutions I've read for this issue are:
Remove the .jars you're not using
Export as a .gradle or ADT project and then export from Android Studio
I have tried removing .jars I am not using, but it appears that I'm using all of the ones that have a significant number of references. There is also a possibility of adding more .jars in the future, so this appears to be a temporary solution.
I have also tried building both a (Legacy) ADT project, and a (New) .gradle project. Both fail with the same error as noted below:
Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskInputUnionFileCollection cannot be cast to org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection
Possible causes for this unexpected error include:<ul><li>Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
There are two suggested solutions to the above issue included in Android Studio - both of which fail to solve the issue.
I did make sure to select File>New>Import Project while importing.
Thanks for the help!
Addyarb
Answer by Addyarb · Jul 01, 2017 at 03:44 AM
I have a current workaround that I thought I would mention, in case anyone else happens upon this answer. I had to end up stripping out some .dlls from my least-needed plugin. This happened to be Firebase in my case. I just removed Firebase completely, and commented out my code to only work on iOS using some pre-processing directives (#IF_UNITY_IOS, #endif).
Not a great workaround, but any attempts to export to Android studio were met with extensive and undocumented gradle errors that I couldn't solve by searching the errors.