1

We have a Xamarin.Android apps built using Xamarin Forms and shared code (.NET Standard 2.0) and trying to build it on our build server where it continuously failing with following errors:

Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. 
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'colorAccent'. 
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'colorPrimary'. 
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'colorPrimaryDark'. 
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'windowActionBar'. 
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'windowActionModeOverlay'. 
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'windowNoTitle'. 
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog'. 
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: No resource found that matches the given name: attr 'colorAccent'. 
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light'. 
Mobile.Android\Resources\values\styles.xml(2,0): Error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'.

Following are notable points:

  • We recently moved from Xamarin.iOS and Xamarin.Android UI to Xamarin.Forms UI. The build agent is able to build the previous builds successfully.
  • The app builds successfully on our local dev machines (tried on 2 different) in release mode.
  • Also tried building the code by simply downloading the app on Build Server and running via VS and it build successfully.
  • Xamarin.Android.Support.v7 and Xamarin.Android.Support.v4 are included.

Solutions I've tried so far include:

  • Making sure the Support libraries and target framework are on same level. (API 25)
  • Making sure the shared code builds before android code.
  • Updated the Android SDKs on Build Server. Android config is same as on my dev machine.
  • Tried with different version of API
  • Cleared content of C:\Users\Admin\AppData\Local\xamarin
  • Rebuild, Restart, Clean bin and obj and other regular stuff

Been struggling with this for 2 days now. ANy help will be much appreciated.

Nitish
  • 104
  • 8
  • Can you build the project on your develop machine locally? – Andy Li-MSFT Sep 14 '18 at 08:19
  • Yes. I can build locally and also on the Build Server by downloading the code and running via VS. Not able to do it through Azure DevOps build pipeline. – Nitish Sep 14 '18 at 16:02
  • There is a similar issue here https://github.com/xamarin/xamarin-android/issues/1934, please check if that helps for your troubleshooting. – Andy Li-MSFT Sep 15 '18 at 01:30
  • I solved it by dumping the already configured pipeline and created a new pipeline using yaml config. I will post the yaml file in answer soon. – Nitish Sep 17 '18 at 16:48

1 Answers1

1

Following is the YAML config that helped me finally build the project.

resources:
- repo: self
  clean: true

queue:
  name: Default
  demands: 
  - MSBuild
  - Xamarin.Android
  - JDK
  - AndroidSDK

variables:
  BuildConfiguration: 'Release'

steps:
- task: NuGetToolInstaller@0
  displayName: 'Use NuGet 4.4.1'
  inputs:
    versionSpec: 4.4.1

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    restoreSolution: '$(Parameters.restorePkgSolution)'

- task: XamarinAndroid@1
  displayName: 'Build Mobile.Android'
  inputs:
    projectFile: Mobile.Android/Mobile.Android.csproj
    outputDirectory: '$(build.binariesdirectory)/$(BuildConfiguration)'
    configuration: '$(BuildConfiguration)'

- task: AndroidSigning@1
  displayName: 'Signing and aligning APK file(s) $(build.binariesdirectory)/$(BuildConfiguration)/*.apk'
  inputs:
    files: '$(Parameters.appFiles)'
    keystoreFile: '<path>'
    keystorePass: <password>
    keystoreAlias: <alias>
    keyPass: <pass>

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact: drop'
  inputs:
    PathtoPublish: '$(build.binariesdirectory)/$(BuildConfiguration)'

Difference between this pipeline and the previous pipeline which was failing is:

  • I was running dotnet restore on the solution in previous pipeline before running MSBuild which I am not doing here.
  • I was building the solution before while here I am building android csproj. IMO, sln should build because the in release config of android, I've set it to only build with android and shared projects.
  • Clean in all steps was set to be true, absence of which was causing a different issue TaskABI not found.
  • In previous pipeline, I was running NuGetInstaller against what I am doing now which is NuGetTollInstaller and then just running nuget restore on it.

So I am still not 100% sure what I was doing wrong but my best guess would be that nuget restore was either not working properly or clean in next steps was cleaning the nuget. If someone wants to investigate further, most welcome. I'll post definite answer if I figure it out but for now this YAML is working.

Nitish
  • 104
  • 8