0
votes

I have a solution that contains an ASP.Net Core web-api project, a Xamarin.Forms app with an Android, iOS and Shared Netstandard library project, along with 5 other NetStandard libraries that are shared between the Xamarin app and the ASP.Net Core app.

I am able to compile and run the Android app on two different local machines, one being Windows 10 and another being macOS Sierra. When I have Visual Studio Team Services (VSTS) clone the repository from BitBucket and build the Android project, it fails to build because of Android resource file issues. I assume the problem is that I don't have VSTS configured correctly, since this runs on two different machines for me without issue. I'm not sure what I have misconfigured in VSTS to solve the issue.

I have a complete reproducible project available for download for uploading to VSTS if anyone needs that.

The build output is large, so I've included the errors themselves below with a link to the entire build output from VSTS.

"d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj" (PackageForAndroid target) (1) -> (_UpdateAndroidResgen target) -> Resources\values\styles.xml(2): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(3): error APT0000: Error: No resource found that matches the given name: attr 'colorAccent'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(2): error APT0000: Error: No resource found that matches the given name: attr 'colorPrimary'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(2): error APT0000: Error: No resource found that matches the given name: attr 'colorPrimaryDark'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(2): error APT0000: Error: No resource found that matches the given name: attr 'windowActionBar'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(4): error APT0000: Error: No resource found that matches the given name: attr 'windowActionModeOverlay'. >[d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(2): error APT0000: Error: No resource found that matches the given name: attr 'windowNoTitle'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(4): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.Dialog'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(4): error APT0000: Error: No resource found that matches the given name: attr 'colorAccent'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(5): error APT0000: Error: No resource found that matches the given name: attr 'colorAccent'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(4): error APT0000: Error: No resource found that matches the given name: attr 'colorPrimary'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(4): error APT0000: Error: No resource found that matches the given name: attr 'colorPrimaryDark'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj] Resources\values\styles.xml(5): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.NoActionBar'. [d:\a\1\s\dotnet\Apps\Mobile\Mobile.Android\Mobile.Android.csproj]

The following is my VSTS Build Definition:

NuGet Restore

enter image description here

Android build

enter image description here

Definition Options

enter image description here

What have I got configured incorrectly that's causing this to fail with the Android resources in VSTS, but not when I build locally?

Local Environment

  • Windows
    • Operating System: Windows 10
    • Visual Studio 2017 15.3 Preview 3
    • dotnet --version: 1.1.0-preview1-005051
  • Mac
    • Operating System: Sierra 10.12.5
    • Visual Studio for Mac Community - 7.1 Preview (build 583)
      • Alpha Channel
    • dotnet --version: 2.0.0-preview3-006815

App Info

  • Xamarin.Forms shared NetStandard library packages:
    • Xamarin.Forms: 2.3.5.256-pre6
    • NetStandard.Library: 1.6.1
  • Xamarin.Android packages
    • Xamarin.Android.Support.Design: 25.3.1
    • Xamarin.Android.Support.v4: 25.3.1
    • Xamarin.Android.Support.v7.AppCompat: 25.3.1
    • Xamarin.Android.Support.v7.CardView: 25.3.1
    • Xamarin.Android.Support.v7.MediaRouter: 25.3.1
  • Xamarin.Android Framework

    • MonoAndroid, Version=v7.1
  • Minimum Android Version: 4.4, API Level 19

  • Target Android Version: 7.1, API Level 25
  • Target Framework: 7.1

Final thoughts

I am using project.json for the Xamarin.Android and Xamarin.iOS projects to maange the nuget packages, instead of packages.config, so I can use transitive dependencies. Is there something specific about my two environments that I need to configure in VSTS? I'm using two different versions of dotnet core as well without any issues, so I'm really confused what's going on here.

1
Take it step by step as if you were a build machine. For example, instead of building your app in VS/VS4M, try to run the command line msbuild against your freshly cloned project in these environments. My guess is that the Resource.designer.cs is not being updated with the proper items from the AppCompat theme. Perhaps try the UpdateAndroidResources target prior to using SignAndroidPackage - developer.xamarin.com/guides/android/under_the_hood/…Jon Douglas
I looked at your link - I understand the targets and stuff a bit now. Do you have any specific reading material that you would recommend for someone who's never done anything with msbuild? All of my experience has been either dotnet core cli or VS/VS4M.Johnathon Sullinger
I had a presentation handy that I converted to a quick blog: jon-douglas.com/2017/07/26/msbuild-basics See the bottom for more materials/resources.Jon Douglas
I can pass the .csproj file directly into msbuild and it builds without issueJohnathon Sullinger
I went to my build output log and copied the msbuild command used to start the build. Excluding the logging components of the command, I copy/pasted locally and executed. The app compiled without issue.Johnathon Sullinger

1 Answers

2
votes

Use "Visual Studio Build" task instead of "Xamarin.Android" task to run the build. Add /t:PackageForAndroid argument in the task if you want to generate apk package. enter image description here