0

After updating the android studio, gradle version and Cordova (incl. platforms) for hybrid project in windows 10 recently, i got this error in Jenkins.

 :app:mergeDebugResourcesC:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-25.4.0.aar\76d6a769daf730ed767830374ebcd3bd\res\drawable\abc_btn_colored_material.xml: error: file not found.

  ...
  ...

 Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details
 :app:mergeDebugResources FAILED

 FAILURE: Build failed with an exception.

 * What went wrong:
 Execution failed for task ':app:mergeDebugResources'.
 > Error: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details

 * Try:
 Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

I searched for a solution for this which should be dynamical and can be managed through Jenkins itself since it is not possible to edit individual platform files.

Originally the error was

 Execution failed for task ':mergeDebugResources'.
 > Error: com.android.builder.internal.aapt.AaptException: Failed to crunch file

which was caused by

Error: File path too long on windows, keep below 240 characters

Workaround for this was to change workspace folder so it is coming to a top level. (eg: C:/Users/[youruser]/yourfolder. Check the link here

Note I added this question and the answer, for the self reference in future and to assist someone who is working with Jenkins.

Thush-Fdo
  • 506
  • 1
  • 9
  • 28

1 Answers1

0

The answer is a simple tweak. Go to

Manage Jenkins --> Configure System --> Global Properties

add an Environment variable

name = GRADLE_USER_HOME
value = C:\Users\[youruser]\devGradle

create a folder "devGradle" (or give it any name) if it is not created already.

The Gradle build script will look for this environment variable and then use the specified directory as the Gradle home directory and will build the project

Thush-Fdo
  • 506
  • 1
  • 9
  • 28