Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle executing dex Error command line too long

I'm building an Android app on windows using gradle and when it comes to last module I'm facing the following error :

* What went wrong:
Execution failed for task ':client:test:dexApiPhoneDebug'.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
        C:\adt-bundle-windows\sdk\build-tools\19.1.0\dx.bat --dex --num-threads= 
.....
Error Code:
    1
Output:
        The command line is too long.

I'm using the command line to build. I know that a similar issue can be solve if using Maven by mapping you project to a disk letter as described here : The command line is too long. in java project with maven

Do you have any idea how can I solve that issue using Gradle?

like image 672
Julien Avatar asked Oct 01 '22 14:10

Julien


2 Answers

I figured out a workaround, it's not perfect but at least do the job.

Basically the project I had was under a long directory like : C:\Development\cloud\my.cloud\main\mycompany\android.

So as a workaround I mapped this folder to a network location, you can do that by using SUBST MS-DOS command or in Explorer under your computer use the GUI "Map a Network Drive". Actually I mapped it to a letter Z: and run my gradle command from there and it worked like a charm.

As I said it's not perfect but at least allowed me to move forward.

like image 142
Julien Avatar answered Oct 18 '22 07:10

Julien


Making a network drive works but seems slower.

Instead of that, I found it better to create a link to the real directory. In Windows it goes like that:

mklink /j "D:\myshortname" "D:\my\long\directory\name\causing\trouble\but\its\not\my\fault\leave\me\alone"

Then I simply open the project from the symlinked directory instead of the real one.

like image 27
Vincent Mimoun-Prat Avatar answered Oct 18 '22 08:10

Vincent Mimoun-Prat