Problem with gradle build (Flutter) in TeamCity

Hi,

I try to setup a Flutter build for Android in TeamCity (2020.1.1). When I try to run the following script from PowerShell build step:

Write-Output '################## Build Flutter ##################';
flutter --suppress-analytics build appbundle;

I get the following error.

[16:25:59][Step 2/2] PowerShell Executable: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
[16:25:59][Step 2/2] Working directory: D:\TeamCity_Agents\Agent2\BuildAgent\work\e1b3aea37ee2e179
[16:25:59][Step 2/2] Command: C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe
[16:25:59][Step 2/2] PowerShell arguments: -NonInteractive, -ExecutionPolicy, unrestricted, -File, D:\TeamCity_Agents\Agent2\BuildAgent\temp\buildTmp\powershell1778449123416613302.ps1
[16:26:00][Step 2/2] ################## Clean Flutter ##################
[16:26:07][Step 2/2] .packages does not exist.
[16:26:07][Step 2/2] Did you run "flutter pub get" in this directory?
[16:26:07][Step 2/2] ################## Build Flutter ##################
[16:26:20][Step 2/2] Running "flutter pub get" in e1b3aea37ee2e179... 7,2s
[16:31:17][Step 2/2] Running Gradle task 'bundleRelease'...
[16:31:17][Step 2/2] FAILURE: Build failed with an exception.
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] * What went wrong:
[16:31:17][Step 2/2] Execution failed for task ':mergeReleaseResources'.
[16:31:17][Step 2/2] > Multiple task action failures occurred:
[16:31:17][Step 2/2] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[16:31:17][Step 2/2] > AAPT2 aapt2-3.5.0-5435860-windows Daemon #0: Daemon startup failed
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] This should not happen under normal circumstances, please file an issue if it does.
[16:31:17][Step 2/2] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] > AAPT2 aapt2-3.5.0-5435860-windows Daemon #1: Daemon startup failed
[16:31:17][Step 2/2] This should not happen under normal circumstances, please file an issue if it does.
[16:31:17][Step 2/2] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] > AAPT2 aapt2-3.5.0-5435860-windows Daemon #2: Daemon startup failed
[16:31:17][Step 2/2]
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] This should not happen under normal circumstances, please file an issue if it does.
[16:31:17][Step 2/2] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] > AAPT2 aapt2-3.5.0-5435860-windows Daemon #4: Daemon startup failed
[16:31:17][Step 2/2] This should not happen under normal circumstances, please file an issue if it does.
[16:31:17][Step 2/2] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[16:31:17][Step 2/2] > AAPT2 aapt2-3.5.0-5435860-windows Daemon #3: Daemon startup failed
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] This should not happen under normal circumstances, please file an issue if it does.
[16:31:17][Step 2/2] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[16:31:17][Step 2/2]
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] > AAPT2 aapt2-3.5.0-5435860-windows Daemon #5: Daemon startup failed
[16:31:17][Step 2/2] This should not happen under normal circumstances, please file an issue if it does.
[16:31:17][Step 2/2] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] > AAPT2 aapt2-3.5.0-5435860-windows Daemon #7: Daemon startup failed
[16:31:17][Step 2/2] This should not happen under normal circumstances, please file an issue if it does.
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] > A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] > AAPT2 aapt2-3.5.0-5435860-windows Daemon #6: Daemon startup failed
[16:31:17][Step 2/2] This should not happen under normal circumstances, please file an issue if it does.
[16:31:17][Step 2/2]
[16:31:17][Step 2/2]
[16:31:17][Step 2/2] * Try:
[16:31:17][Step 2/2] 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.
[16:31:17][Step 2/2] * Get more help at https://help.gradle.org
[16:31:17][Step 2/2] BUILD FAILED in 4m 54s
[16:31:17][Step 2/2]
[16:31:18][Step 2/2] Running Gradle task 'bundleRelease'... 296,5s (!)
[16:31:18][Step 2/2] The built failed likely due to AndroidX incompatibilities in a plugin. The tool is about to try using Jetfier to solve the incompatibility.
[16:31:18][Step 2/2] Building plugin background_fetch...
[16:31:23][Step 2/2]
[16:31:23][Step 2/2] Running Gradle task 'assembleAarRelease'... 4,6s
[16:31:23][Step 2/2] FAILURE: Build failed with an exception.
[16:31:23][Step 2/2] * Where:
[16:31:23][Step 2/2] Build file 'D:\flutter\.pub-cache\hosted\pub.dartlang.org\background_fetch-0.5.6\android\build.gradle' line: 18
[16:31:23][Step 2/2]
[16:31:23][Step 2/2] * What went wrong:
[16:31:23][Step 2/2] A problem occurred evaluating root project 'background_fetch'.
[16:31:23][Step 2/2] > Plugin with id 'com.android.library' not found.
[16:31:23][Step 2/2]
[16:31:23][Step 2/2] * Try:
[16:31:23][Step 2/2] 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.
[16:31:23][Step 2/2]
[16:31:23][Step 2/2] * Get more help at https://help.gradle.org
[16:31:23][Step 2/2]
[16:31:23][Step 2/2] BUILD FAILED in 3s
[16:31:23][Step 2/2]
[16:31:23][Step 2/2] The plugin background_fetch could not be built due to the issue above.

 

When I run the same script from PowerShell directly (under the given location) it's all working fine. The build agent has the "-ExecutionPolicy unrestricted".

Any help would be highly welcome.

0
1 comment
Avatar
Permanently deleted user

I was able to resolve the problem with the "RunAs" plugin as described here https://blog.jetbrains.com/teamcity/2017/09/introducing-teamcity-runas-plugin/

It's a pity this is not a default plugin/option but needs to be installed by hand.

0

Please sign in to leave a comment.