Android build failing on AzureDevOps(VSTS) build agent with Error retrieving parent for item

Hi,

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.

Best Answer

  • NitishKumarSharmaNitishKumarSharma US ✭✭
    Accepted Answer

    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: [email protected]
      displayName: 'Use NuGet 4.4.1'
      inputs:
        versionSpec: 4.4.1
    
    - task: [email protected]
      displayName: 'NuGet restore'
      inputs:
        restoreSolution: '$(Parameters.restorePkgSolution)'
    
    - task: [email protected]
      displayName: 'Build Mobile.Android'
      inputs:
        projectFile: Mobile.Android/Mobile.Android.csproj
        outputDirectory: '$(build.binariesdirectory)/$(BuildConfiguration)'
        configuration: '$(BuildConfiguration)'
    
    - task: [email protected]
      displayName: 'Signing and aligning APK file(s) $(build.binariesdirectory)/$(BuildConfiguration)/*.apk'
      inputs:
        files: '$(Parameters.appFiles)'
        keystoreFile: '<path>'
        keystorePass: <password>
        keystoreAlias: <alias>
        keyPass: <pass>
    
    - task: [email protected]
      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 not this yaml is working.

Answers

  • jezhjezh Member, Xamarin Team mod

    @NitishKumarSharma

    please add a diagnostic build output about this issue. (As a file attachment or gist link), that would be really appreciated! Just as the follows.
    1. Help->Xamarin->Zip Logs(last 7 days)
    2. Tools ->Options
    .

  • @jezh Thanks for the suggestion. I solved it though. I dumped the old pipeline and created a new pipeline by writing a new yaml. Somehow, even when I was creating new pipeline using UI, ti was still failing. I created a new config in CLI. I will post the file as answer soon.
    Thanks

  • NitishKumarSharmaNitishKumarSharma USMember ✭✭
    Accepted Answer

    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: [email protected]
      displayName: 'Use NuGet 4.4.1'
      inputs:
        versionSpec: 4.4.1
    
    - task: [email protected]
      displayName: 'NuGet restore'
      inputs:
        restoreSolution: '$(Parameters.restorePkgSolution)'
    
    - task: [email protected]
      displayName: 'Build Mobile.Android'
      inputs:
        projectFile: Mobile.Android/Mobile.Android.csproj
        outputDirectory: '$(build.binariesdirectory)/$(BuildConfiguration)'
        configuration: '$(BuildConfiguration)'
    
    - task: [email protected]
      displayName: 'Signing and aligning APK file(s) $(build.binariesdirectory)/$(BuildConfiguration)/*.apk'
      inputs:
        files: '$(Parameters.appFiles)'
        keystoreFile: '<path>'
        keystorePass: <password>
        keystoreAlias: <alias>
        keyPass: <pass>
    
    - task: [email protected]
      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 not this yaml is working.

Sign In or Register to comment.