Gradle build for android failed with app:mergeDebugResources in TeamCity

Hello All,

When I build my android project in Android Studio it works fine. But when I try to build the same project in TeamCity its giving app:mergeDebugResources error with Aapt2Exception: AAPT error.

This is my project https://github.com/burhanrashid52/SampleApp

I have tried disabling aapt2 as well but still the same issue.

:app:mergeDebugResources (9s)
[21:45:31][:app:mergeDebugResources] AAPT err(Facade for 811974709) : No Delegate set : lost message:\\?\C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\6fea1366c013f067ed93d071250ff54d\res\drawable-hdpi-v4\abc_textfield_search_default_mtrl_alpha.9.png ERROR: Unable to open PNG file
[21:45:31][:app:mergeDebugResources] AAPT err(Facade for 811974709) : No Delegate set : lost message:\\?\C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\6fea1366c013f067ed93d071250ff54d\res\drawable-xhdpi-v4\abc_ab_share_pack_mtrl_alpha.9.png ERROR: Unable to open PNG file
[21:45:31][:app:mergeDebugResources] AAPT err(Facade for 811974709) : No Delegate set : lost message:\\?\C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\6fea1366c013f067ed93d071250ff54d\res\drawable-xhdpi-v4\abc_textfield_search_activated_mtrl_alpha.9.png ERROR: Unable to open PNG file
[21:45:31][:app:mergeDebugResources] AAPT err(Facade for 811974709) : No Delegate set : lost message:\\?\C:\Windows\System32\config\systemprofile\.gradle\caches\transforms-1\files-1.1\appcompat-v7-28.0.0.aar\6fea1366c013f067ed93d071250ff54d\res\drawable-xhdpi-v4\abc_list_focused_holo.9.png ERROR: Unable to open PNG file
 

.....

 
[21:45:35]
[21:45:35]Process exited with code 1
[21:45:35]Gradle failure report
[21:45:35][Gradle failure report] FAILURE: Build failed with an exception.
[21:45:35][Gradle failure report]
[21:45:35][Gradle failure report] * What went wrong:
[21:45:35][Gradle failure report] Execution failed for task ':app:mergeDebugResources'.
[21:45:35][Gradle failure report] > java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: AAPT error: check logs for details
[21:45:35][Gradle failure report]
[21:45:35][Gradle failure report] * Try:
[21:45:35][Gradle failure report] Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
[21:45:35][Gradle failure report]
[21:45:35][Gradle failure report] * Get more help at https://help.gradle.org
[21:45:35][Gradle failure report]
[21:45:35][Gradle failure report] BUILD FAILED in 39s
0
3 comments

I would recommend running with the --stacktrace or --debug to open extra debug logging. I'm afraid that the error message can mean tons of different issues, so helping is going to be hard. It's very likely that the issues is between the different environments, or if you aren't using the gradle wrapper, it might be an issue with different gradle versions.

 

In any case, this is mostly a gradle issue, I'd recommend checking for the error message you get, especially if you can get more details with the debug tracing. If after looking for specific gradle issues you can't find any problem with the set up, please follow the steps here for reporting: https://confluence.jetbrains.com/display/TCD18/Common+Problems#CommonProblems-BuildworkslocallybutfailsormisbehavesinTeamCity

0

I have tried with --stacktrace or --debug. It's logging the same error as above just the number of file Unable to open PNG file increases.

0
Avatar
Permanently deleted user

I've found this:

https://stackoverflow.com/questions/43674890/jenkins-gradle-appmergedebugresources-unable-to-open-png-file

It fixed my problem which was the same as yours, same error. The cause is TeamCity putting the cache somewhere that's too long for windows to access (assuming you're on windows too), you have to create an agent environment variable called GRADLE_USER_HOME to place the cache somewhere shallow in the file system

0

Please sign in to leave a comment.