Xamarin-android: Ubuntu: projects fail to build with msbuild

Created on 4 Feb 2018  路  26Comments  路  Source: xamarin/xamarin-android

The Problem

With some work I got everything to build on Ubuntu, had to put the android tools/dnk inside the repo.

Not exactly sure how to use this, but with msbuild I get the same Mono.Android not found error, with 29000 other errors about missing assemblies.
Using the xabuild in the scripts folder produces a different error. This is sort of a "big" project, but what's going on? Seems like a simple fix to someone who knows what they're doing... v7.1 is not supported??

Build FAILED.

Warnings:

/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj (SignAndroidPackage) ->

/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj: warning : Target '_GetRestoreTargetFrameworksOutput', not found in the project
/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj: warning : Target 'IncrementalClean', not found in the project

Errors:

/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj (SignAndroidPackage) ->
/media/shane/RaptorWS/etc/git_clones/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets (_SetLatestTargetFrameworkVersion target) ->

/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj: error XA0001: Unsupported or invalid $(TargetFrameworkVersion) value of 'v7.1'. Please update your Project Options.

2 Warning(s)
1 Error(s)

need-info

Most helpful comment

@gamesguru, @mserougi: My suspicion is that you don't actually have Xamarin.Android installed. Xamarin.Android is not included as part of the mono package; it is entirely separate.

Have you installed one of the xamarin-android-oss*.deb files from: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-linux/lastSuccessfulBuild/Azure/

If not, please try to do so, and see if that improves things.

All 26 comments

apologies, xabuild is actually using xbuild by default. Could you point me in a clearer direction?

shane@ubuHome:/media/shane/RaptorWS/etc/git_clones/xamarin-android/tools/scripts$ ./xabuild '/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj' 

>>>> xbuild tool is deprecated and will be removed in future updates, use msbuild instead <<<<

XBuild Engine Version 14.0
Mono, Version 5.10.0.94
Copyright (C) 2005-2013 Various Mono authors

Build started 2/8/2018 10:17:44 PM.
__________________________________________________
Project "/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj" (default target(s)):
/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj:  warning : Target '_GetRestoreTargetFrameworksOutput', not found in the project
/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj:  warning : Target 'IncrementalClean', not found in the project
    Target _SetLatestTargetFrameworkVersion:
        Found Java SDK version 1.8.0.
/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj: error XA0001: Unsupported or invalid $(TargetFrameworkVersion) value of 'v7.1'. Please update your Project Options.
    Task "ResolveSdks" execution -- FAILED
    Done building target "_SetLatestTargetFrameworkVersion" in project "/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj".-- FAILED
Done building project "/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj".-- FAILED

Build FAILED.

Warnings:

/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj (default targets) ->

    /media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj:  warning : Target '_GetRestoreTargetFrameworksOutput', not found in the project
    /media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj:  warning : Target 'IncrementalClean', not found in the project

Errors:

/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj (default targets) ->
/media/shane/RaptorWS/etc/git_clones/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Xamarin/Android/Xamarin.Android.Common.targets (_SetLatestTargetFrameworkVersion target) ->

    /media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj: error XA0001: Unsupported or invalid $(TargetFrameworkVersion) value of 'v7.1'. Please update your Project Options.

     2 Warning(s)
     1 Error(s)

Time Elapsed 00:00:01.2418140

when attempting to build with msbuild i am getting a missing Xamarin.CSharp.Targets file in the /usr/lib/mono/xbuild/Xamarin directory

Executing task: Android-Build
Microsoft (R) Build Engine version 15.4.0.0 ( Wed Nov 29 14:56:11 UTC 2017) for Mono
Copyright (C) Microsoft Corporation. All rights reserved.

Build started 2/10/2018 2:52:45 PM.
Project "/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj" on node 1 (SignAndroidPackage target(s)).
/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj(515,3): error MSB4019: The imported project "/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
Done Building Project "/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj" (SignAndroidPackage target(s)) -- FAILED.

Build FAILED.

"/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj" (SignAndroidPackage target) (1) ->
/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj(515,3): error MSB4019: The imported project "/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.

0 Warning(s)
1 Error(s)

Time Elapsed 00:00:00.11
An error occurred when executing task 'Android-Build'.
Error: One or more errors occurred.
MSBuild: Process returned an error (exit code 1).

@gamesguru to use msbuild with xabuild run it as follows:

MSBUILD=msbuild xabuild

Also, make sure you have the following Ubuntu packages installed:

msbuild-libhostfxr
msbuild-sdkresolv

I recommend you use the preview version of Mono.

Regarding the missing Xamarin.CSharp.Targets in /usr/lib/mono/xbuild/, create a symlink from /usr/lib/mono/xbuild/Xamarin to your Xamarin.Android's [PATH_TO_XAMARIN_ANDROID_ROOT]/bin/${CONFIGURATION}/lib/xamarin.android/xbuild/Xamarin directory

where do i put the MSBUILD=?
have the preview release of mono, and those packages already thanks.

Now I've created the symlink, but am getting this error still:
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(620,2): error MSB3644: The reference assemblies for framework "MonoAndroid,Version=v1.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

I'm running into the same problem with the missing Xamarin.Android.CSharp.targets. It seems I don't have xamarin-android installed to begin with, but I did install Mono as a whole:

echo ">> Install Mono"
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/ubuntu preview-xenial main" | sudo tee /etc/apt/sources.list.d/mono-official-preview.list
apt-get update
apt-get install -y mono-complete

@gamesguru It seems you had to do something extra to install xamarin-android?

@gamesguru, @mserougi: My suspicion is that you don't actually have Xamarin.Android installed. Xamarin.Android is not included as part of the mono package; it is entirely separate.

Have you installed one of the xamarin-android-oss*.deb files from: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-linux/lastSuccessfulBuild/Azure/

If not, please try to do so, and see if that improves things.

Microsoft.CSharp.Targets case sensitivity issue is fixed at https://github.com/xamarin/xamarin-android/commit/d207275.

(To make things clear, there is no Xamarin.CSharp.Targets. There are only Xamarin.Android.CSharp.targets, Microsoft.CSharp.targets and Xamarin.Android.Common.targets.)

@gamesguru MSBUILD= goes before xabuild on the same line when running from the terminal:

$ MSBUILD=msbuild xabuild your.csproj-or-sln

The syntax sets environment variable just for the command that follows the envvar assignment (you can assign more variables this way)

So I installed Xamarin.Android, managed by moving things around until the process was able to find Xamarin.Android.CSharp.targets. The I came across another error which was pointed out by @gamesguru up there:

/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(620,2): error MSB3644: The reference assemblies for framework "MonoAndroid,Version=v1.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.

So before running the script, I added MSBUILD=msbuild xbuild Sensor.Droid.csproj, error was gone but something else came up:

/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: error : Error executing task ResolveSdks: Value cannot be null

So I figured maybe it's because I didn't install the package msbuild-sdkresolv, but that package doesn't exist, say's it's unable to locate package.

Can anyone who did build a Xamarin project paste their script here please?

i've installed the debian package for xamarin-android.oss a version 8.3.99.10.
how come this is even necessary? I thought that's why I compiled the source? I would eventually like to get xabuild in the environment path, so i can run it from any terminal
@jonpryor And is there any way to look and see if everything was installed in the necessary places because sir I am getting the exact same error todo with v7.1

Build FAILED.

  /usr/lib/mono/xbuild/15.0/Imports/Microsoft.Common.props/ImportBefore/Microsoft.NuGet.ImportBefore.props(16,3): warning MSB4011: "/media/shane/RaptorWS/etc/git_clones/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Microsoft/NuGet/Microsoft.NuGet.props" cannot be imported again. It was already imported at "/media/shane/RaptorWS/etc/git_clones/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/15.0/Imports/Microsoft.Common.props/ImportBefore/Microsoft.NuGet.ImportBefore.props (16,3)". This is most likely a build authoring error. This subsequent import will be ignored. [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  /usr/lib/mono/xbuild/15.0/Microsoft.Common.targets/ImportAfter/Microsoft.NET.Build.Extensions.targets(19,3): warning MSB4011: "/media/shane/RaptorWS/etc/git_clones/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Microsoft/Microsoft.NET.Build.Extensions/Microsoft.NET.Build.Extensions.targets" cannot be imported again. It was already imported at "/media/shane/RaptorWS/etc/git_clones/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/15.0/Microsoft.Common.targets/ImportAfter/Microsoft.NET.Build.Extensions.targets (19,3)". This is most likely a build authoring error. This subsequent import will be ignored. [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  /usr/lib/mono/xbuild/15.0/Microsoft.Common.targets/ImportAfter/Microsoft.NuGet.ImportAfter.targets(16,3): warning MSB4011: "/media/shane/RaptorWS/etc/git_clones/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/Microsoft/NuGet/Microsoft.NuGet.targets" cannot be imported again. It was already imported at "/media/shane/RaptorWS/etc/git_clones/xamarin-android/bin/Debug/lib/xamarin.android/xbuild/15.0/Microsoft.Common.targets/ImportAfter/Microsoft.NuGet.ImportAfter.targets (16,3)". This is most likely a build authoring error. This subsequent import will be ignored. [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]


"/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj" (default target) (1) ->
(_SetLatestTargetFrameworkVersion target) -> 
  /media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj : error XA0001: Unsupported or invalid $(TargetFrameworkVersion) value of 'v7.1'. Please update your Project Options.

    3 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.53

@grendello
Made progress by overriding xbuild with msbuild and changing target framework to v8.1 in the .csproj file. But now we have a new problem that supporting projects won't build because of

error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.

Your project contains <Project Sdk="Microsoft.NET.Sdk" ... /> which is not supported by Xamarin.Android.

@atsushieno I've installed the core .net package for ubuntu, is there anything I can do to get this project to build? Why are my colleagues able to build on a mac?

There are more than one possibilities why you don't get things work. But at least Xamarin.Android is not .NET Core based. Any project that is written in .NET Core manner won't build (at least from ourselves).
When .NET Core project builds with msbuild, that means your msbuild works for .NET Core and it may be msbuild for .NET Core, not mono. There are msbuild for mono and msbuild for .NET Core. They are different frameworks which has their own set of MSBuild support files for each.
You might be just seeing .NET Standard library project build failure which just happens to be in the same solution. Again, there are more than one possibilities and I cannot list all of them.

To diagnose your local issues, you had better begin with simple standard Xamarin.Android project. Hello World. Then complicated projects. Otherwise you won't find the exact cause of the problem.

@atsushieno I've followed your advice, we made a single view app that builds on Windows. Copied over to Linux and we had the following error:
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1201,2): error MSB3030: Could not copy the file "Resources/values/strings.xml" because it was not found.

hmm... I went to the folder and found a file named Strings.xml with a capital 'S', renamed it to hopefully solve case-sensitivity issues but now am greeted by a new set of errors. Am awaiting advice on how to proceed,

_DefineBuildTargetAbis: Build target ABI: armeabi-v7a Resources/values/styles.xml(5): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. [/home/shane/myxamarinapp/myxamarinapp/myxamarinapp.csproj] Resources/values/styles.xml(9): error APT0000: No resource found that matches the given name: attr 'colorAccent'. [/home/shane/myxamarinapp/myxamarinapp/myxamarinapp.csproj] Resources/values/styles.xml(7): error APT0000: No resource found that matches the given name: attr 'colorPrimary'. [/home/shane/myxamarinapp/myxamarinapp/myxamarinapp.csproj] Resources/values/styles.xml(8): error APT0000: No resource found that matches the given name: attr 'colorPrimaryDark'. [/home/shane/myxamarinapp/myxamarinapp/myxamarinapp.csproj] Resources/values/styles.xml(13): error APT0000: No resource found that matches the given name: attr 'windowActionBar'. [/home/shane/myxamarinapp/myxamarinapp/myxamarinapp.csproj] Resources/values/styles.xml(14): error APT0000: No resource found that matches the given name: attr 'windowNoTitle'. [/home/shane/myxamarinapp/myxamarinapp/myxamarinapp.csproj] Resources/values/styles.xml(17): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'ThemeOverlay.AppCompat.Dark.ActionBar'. [/home/shane/myxamarinapp/myxamarinapp/myxamarinapp.csproj] Resources/values/styles.xml(19): error APT0000: Error retrieving parent for item: No resource found that matches the given name 'ThemeOverlay.AppCompat.Light'. [/home/shane/myxamarinapp/myxamarinapp/myxamarinapp.csproj]

@gamesguru: This looks like an issue with the Support library/component, which isn't something that has been tested at all on Linux...except via Xamarin.Forms-Performance-Integration test.

In the meantime, I would suggest removing the bin and obj directories, building with msbuild /v:diag (or equivalent), and providing the build log.

Issue with String.xml vs strings.xml has been fixed.

As for the build, we used a project without a solution directory and API level 27. Not sure that's important. We could test earlier API levels for library compatibility?

The full output is rather long, can be viewed here: https://gist.github.com/gamesguru/0efa6d3ef0c7a19d458810bc8635bb67

I got the large project to build on another machine! Everything is working perfectly, right down to the /t:SignAndroidPackage target.

But now I'm having a peculiar problem when trying to build a release configuration.
Passing in the /p:Configuration=Release switch is definitely the culprit. Do you think this is something with our project or something with the support libraries? Debug is giving me no problems.

I attached both logs.
release_build.zip
debug_build.zip

With the release configuration, if you scroll to the bottom you'll see the build errors I'm having:

"/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj" (SignAndroidPackage target) (1) ->
(_UpdateAndroidResgen target) -> 
  Resources/layout/card_generator.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/offline_state'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/card_generator.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/relay_error_state'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/card_generator_octp.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/offline_state'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/card_generator_octp.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/relay_error_state'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FanModeDialog.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/hvac_dialog_fragment_header_fan_mode'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentCloudLogin.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/cloudLoginHeader'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentDetailView.axml(2): error APT0000: No resource found that matches the given name (at 'fontFamily' with value '@string/havc_mode_display_font'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentDetailView.axml(2): error APT0000: No resource found that matches the given name (at 'fontFamily' with value '@string/hvac_default_font'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentSettings.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/restart_wizard_header'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentSettings.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/restart_wizard'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentSettings.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/restart_wizard_button'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentSettings.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/login_account_button'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentWizardEnterBluetoothUnlockCode.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/bluetooth_sticker_pin_description'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentWizardSearchBluetooth.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/bluetooth_sticker_device_name_description'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentWizardSearchBluetooth.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/search_again'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentWizardSearchWifiNetwork.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/wifi_router_sticker_description'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentWizardWelcome.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/welcomeHeader'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/FragmentWizardWelcome.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/welcomeMainText'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/HeatModeDialog.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/hvac_dialog_fragment_header_heat_mode'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/HeatModeDialog.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/hvac_dialog_fragment_header_heat_source'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/HeatModeDialog.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/hvac_close'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/listitem_relay.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/offline_state'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout/listitem_relay.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/relay_error_state'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout-v21/listitem_relay.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/offline_state'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
  Resources/layout-v21/listitem_relay.axml(2): error APT0000: No resource found that matches the given name (at 'text' with value '@string/relay_error_state'). [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]

    27 Warning(s)
    25 Error(s)

Time Elapsed 00:00:19.96

Guess we still have the issue with Strings.xml needing to be renamed strings.xml (in the Resources/values folder). That's what was confusing me. The above errors are gone. But I'm still facing issues with the release build.

It's not finding the android-ndk now for some reason. I'm having this issue basically: https://forums.xamarin.com/discussion/101908/getting-error-could-not-find-a-part-of-the-path-d-platforms-when-building-on-vsts
Tried putting environment variables, but no dice. Again, Debug configuration is working fine.

(SignAndroidPackage target) (1) ->
(_BuildApkEmbed target) -> 
  /usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2454,3):
error : Could not find a part of the path '/platforms'.

    60 Warning(s)
    1 Error(s)

Based on the build log, it's not finding the Java SDK either...

MonoAndroid Tools: /usr/lib/xamarin.android/xbuild/Xamarin/Android/
Android Platform API level: 27
TargetFrameworkVersion: v8.1
Android NDK: /
Android SDK: /media/shane/RaptorWS/Ubuntuware/android-sdk/
Android SDK Build Tools: /media/shane/RaptorWS/Ubuntuware/android-sdk/build-tools/27.0.3/
Java SDK: /usr/

The issue with Release config went away when I set BundleAssemblies to false in the csproj file.

But now I'm having an issue with a special release configuration that uses LLVM. I set LLVM to false on that config and while XA3005 disappeared but we're still getting XA5101. Attached all three build configs below. Curious what you guys will find out. Thanks

(_BuildApkEmbed target) ->
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3005: The detected Android NDK version is incompatible with the targeted LLVM configuration, please upgrade to NDK r10d or newer. [/media/shane/RaptorWS/etc/git_clones/onecontrol/OneControl.Android/OneControl.Android.csproj]
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error : error XA5101: Missing Android NDK toolchains directory '/toolchains'. Please install the Android NDK.

Here is the troublesome release config:

  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
    <OutputPath>bin\Release_OCTP</OutputPath>
    <Optimize>true</Optimize>
    <ErrorReport>prompt</ErrorReport>
    <DefineConstants>__ANDROID__;OCTP</DefineConstants>
    <BundleAssemblies>true</BundleAssemblies>
    <WarningLevel>4</WarningLevel>
    <ConsolePause>false</ConsolePause>
    <RunCodeAnalysis>false</RunCodeAnalysis>
    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
    <EmbedAssembliesIntoApk>True</EmbedAssembliesIntoApk>
    <Debugger>Xamarin</Debugger>
    <DebugSymbols>False</DebugSymbols>
    <DebugType>
    </DebugType>
    <AndroidSupportedAbis>armeabi-v7a</AndroidSupportedAbis>
    <AndroidCreatePackagePerAbi>true</AndroidCreatePackagePerAbi>
    <AndroidEnableSGenConcurrent>false</AndroidEnableSGenConcurrent>
    <AotAssemblies>true</AotAssemblies>
    <EnableLLVM>true</EnableLLVM>

The one which works out of the box:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>True</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug</OutputPath>
    <DefineConstants>DEBUG;__ANDROID__</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AndroidLinkMode>None</AndroidLinkMode>
    <ConsolePause>false</ConsolePause>
    <RunCodeAnalysis>false</RunCodeAnalysis>
    <BundleAssemblies>False</BundleAssemblies>
    <Debugger>Xamarin</Debugger>
    <AndroidSupportedAbis>arm64-v8a;armeabi-v7a;x86;x86_64</AndroidSupportedAbis>

And the one which works if BudleAssemblies is False:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <Optimize>false</Optimize>
    <OutputPath>bin\Release</OutputPath>
    <DefineConstants>__ANDROID__</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <ConsolePause>false</ConsolePause>
    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
    <AndroidLinkMode>SdkOnly</AndroidLinkMode>
    <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>
    <BundleAssemblies>true</BundleAssemblies>
    <Debugger>Xamarin</Debugger>
    <DebugSymbols>False</DebugSymbols>
    <AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a;x86_64</AndroidSupportedAbis>
    <AndroidCreatePackagePerAbi>true</AndroidCreatePackagePerAbi>
    <AndroidHttpClientHandlerType>System.Net.Http.HttpClientHandler</AndroidHttpClientHandlerType>
    <AndroidTlsProvider>btls</AndroidTlsProvider>
    <AotAssemblies>false</AotAssemblies>
    <EnableLLVM>false</EnableLLVM>
  </PropertyGroup>

To use BundleAssemblies (mkbundle) you have to specify Android NDK (via /p:AndroidNdkDirectory=/path/to/ndk). People with IDEs can specify it as part of SDK Locations.

Yes that's fixed both BundleAssemblies and LLVM. Thanks a ton. I have the latest MonoDevelop but building Xamarin.Android projects from it still isn't unsupported.

Next roadblock is with the ahead-of-time compiler (AOT) with error XA3001, any tricks to get that working on Linux? Here are my errors:

(SignAndroidPackage target) (1) ->
(_BuildApkEmbed target) ->
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3001: Could not AOT the assembly: FFImageLoading.dll
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3001: Could not AOT the assembly: Acr.UserDialogs.dll
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3001: Could not AOT the assembly: FFImageLoading.Svg.Platform.dll
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3001: Could not AOT the assembly: Acr.Support.Android.dll
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3001: Could not AOT the assembly: OneControl.Android.dll
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3001: Could not AOT the assembly: FFImageLoading.Forms.dll
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3001: Could not AOT the assembly: FFImageLoading.Platform.dll
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3001: Could not AOT the assembly: AndHUD.dll
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3001: Could not AOT the assembly: FormsViewGroup.dll
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3001: Could not AOT the assembly: FFImageLoading.Transformations.dll
/usr/lib/mono/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2426,3): error XA3001: Could not AOT the assembly: FFImageLoading.Forms.Platform.dll

64 Warning(s)
11 Error(s)

The size of the apk in kilobytes of the third (bottom) configuration is also suspicious when compared against binaries from Windows or macOS. About 20-40% larger, and sometimes the app fails to launch with these weird flags enabled in the project. Windows is building better at this point.

The logcat from when the app fails to launch with bundled assemblies (we are using NDK v17.1.4828580)

06-18 23:04:23.662  2074  2141 W WindowManager: Failed looking up window
06-18 23:04:23.662  2074  2141 W WindowManager: java.lang.IllegalArgumentException: Requested window android.view.ViewRootImplAO$WEx@433a023 does not exist
06-18 23:04:23.662  2074  2141 W WindowManager:     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9427)
06-18 23:04:23.662  2074  2141 W WindowManager:     at com.android.server.wm.WindowManagerService.windowForClientLocked(WindowManagerService.java:9418)
06-18 23:04:23.662  2074  2141 W WindowManager:     at com.android.server.wm.WindowManagerService.finishDrawingWindow(WindowManagerService.java:3682)
06-18 23:04:23.662  2074  2141 W WindowManager:     at com.android.server.wm.Session.finishDrawing(Session.java:243)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2534)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2120)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1137)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6228)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.view.Choreographer.doCallbacks(Choreographer.java:670)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.view.Choreographer.doFrame(Choreographer.java:606)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.os.Handler.handleCallback(Handler.java:739)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.os.Handler.dispatchMessage(Handler.java:95)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.os.Looper.loop(Looper.java:148)
06-18 23:04:23.662  2074  2141 W WindowManager:     at android.os.HandlerThread.run(HandlerThread.java:61)
06-18 23:04:23.662  2074  2141 W WindowManager:     at com.android.server.ServiceThread.run(ServiceThread.java:46)
Was this page helpful?
0 / 5 - 0 ratings