Gradle dex command execution Command line error too long

I am building an Android application for Windows using gradle, and when it comes to the last module, I encounter 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 use the command line to build. I know that a similar problem can be solved when using Maven by matching the project with the drive letter, as described here: The command line is too long. in java project with maven

Do you have any ideas how I can solve this problem using Gradle?

+4
source share
3 answers

, , , , .

, , , : C:.\\\my.cloud\\MyCompany\

, , , SUBST MS-DOS , " ". Z: gradle, .

, , , , .

+2

, .

. Windows :

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

.

+2

, Dex gradle. , Dex "preDex". Dex , .

, root build.gradle

task (configureDex) {
  gradle.taskGraph.beforeTask { Task task ->
      if (task.name.contains("dex") && !task.name.contains("predex")) {
        task.libraries = findPredexTask().outputFolder
      }
  }
}

def findPredexTask(){
  gradle.taskGraph.getAllTasks().findAll{ task ->
    task.name.toLowerCase().contains('predex')
  }
}

, , , .

, "dex" "predex" , android gradle .

0
source

Source: https://habr.com/ru/post/1544004/


All Articles