Search code examples
androidjenkinsgradleandroid-gradle-pluginaapt2

Jenkins - Execution failed for task ':app:mergeDebugResources'


I am trying to work with Jenkins however I cannot build the apk with it as I am having issue with AAPT2 and Gradle.

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugResources'.
> Multiple task action failures occurred:
   > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
      > Android resource compilation failed
        ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\b478eb984dbbd1317dab9bfd9689b3aa\transformed\appcompat-1.3.0\res\drawable-hdpi-v4\abc_list_divider_mtrl_alpha.9.png: AAPT: error: file not found.
            
   > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
      > Android resource compilation failed
        ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\b478eb984dbbd1317dab9bfd9689b3aa\transformed\appcompat-1.3.0\res\drawable-xhdpi-v4\abc_list_divider_mtrl_alpha.9.png: AAPT: error: file not found.
            
   > A failure occurred while executing com.android.build.gradle.internal.res.Aapt2CompileRunnable
      > Android resource compilation failed
        ERROR:C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-3\b478eb984dbbd1317dab9bfd9689b3aa\transformed\appcompat-1.3.0\res\drawable-mdpi-v4\abc_list_divider_mtrl_alpha.9.png: AAPT: error: file not found.

I already read tons of SO question that may share same issue to my case saying that it has something to do with the file path being too long but I still cannot find any solution.

UPDATE

I tried to change Android Studio Gradle home similar to what Jenkins is using and received similar error which indicates that it may really have something to do with long file path.

I think the final question will be how to change Jenkins Gradle Home?

enter image description here


Solution

  • You need to replace \ with \\ if you are giving path with jenkins in Windows.
    May be if file path is too huge or that is the root cause you can try mounting the directory to a short path

    EDIT : Based on your modified question :
    Open Jenkins dashboard. Navigate to Manage Jenkins-> Configure System. Under the Global properties section add another environment variable named GRADLE_USER_HOME as shown below.
    enter image description here