Repository navigation
Can't build .NET 7 android projects #7939
Description
Android application type
.NET Android (net7.0-android, etc.)
Affected platform version
VS 2022 17.5.3, .NET SDK 7.0.200, osx.13-arm64, Mono 6.12.0.188
Description
Can't build .NET 7.0 android project, newly created from template in visual studio. If i change to .net6.0-android however, it will build.
Csproj:
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net7.0-android</TargetFramework> <SupportedOSPlatformVersion>23</SupportedOSPlatformVersion> <OutputType>Exe</OutputType> <Nullable>enable</Nullable> <ImplicitUsings>enable</ImplicitUsings> <ApplicationId>com.companyname.AndroidApp1</ApplicationId> <ApplicationVersion>1</ApplicationVersion> <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion> <TargetFrameworkVersion>v11.0</TargetFrameworkVersion> </PropertyGroup>
My system:
.NET SDK:
Version: 7.0.202
Commit: 6c74320bc3
Runtime Environment:
OS Name: Mac OS X
OS Version: 13.3
OS Platform: Darwin
RID: osx.13-arm64
Base Path: /usr/local/share/dotnet/sdk/7.0.202/
Host:
Version: 7.0.4
Architecture: arm64
Commit: 0a396acafe
.NET SDKs installed:
6.0.407 [/usr/local/share/dotnet/sdk]
7.0.202 [/usr/local/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
x64 [/usr/local/share/dotnet/x64]
registered at [/etc/dotnet/install_location_x64]
Environment variables:
Not set
global.json file:
Not found
Workloads:
Installed Workload Id Manifest Version Installation Source
wasm-tools 7.0.4/7.0.100 SDK 7.0.200
macos 13.1.1040/7.0.100 SDK 7.0.200
maui-maccatalyst 7.0.59/7.0.100 SDK 7.0.200
maui-ios 7.0.59/7.0.100 SDK 7.0.200
maui-android 7.0.59/7.0.100 SDK 7.0.200
tvos 16.1.1537/7.0.100 SDK 7.0.200
android 33.0.26/7.0.100 SDK 7.0.200
Steps to Reproduce
- Install android workload
- Create .NET android project from visual studio template
-
- Build solution (either via visual studio or command line)
Did you find any workaround?
No
Relevant log output
Xamarin.Android.Common.targets(3,3): Error XA3006: Could not compile native assembly file: environment.arm64-v8a.ll
stderr | /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.26/tools/Darwin/binutils/bin/llc: error: /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.26/tools/Darwin/binutils/bin/llc: environment.arm64-v8a.ll:554:7: error: expected value token
stderr | i32 −1, ; apk_fd
(XA3006) (AndroidApp1)
Xamarin.Android.Common.targets(1979, 3): [XA3006] Could not compile native assembly file: environment.x86.ll
stderr | /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.26/tools/Darwin/binutils/bin/llc: error: /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.26/tools/Darwin/binutils/bin/llc: environment.x86.ll:593:7: error: expected value token
stderr | i32 −1, ; apk_fd
Xamarin.Android.Common.targets(1979, 3): [XA3006] Could not compile native assembly file: environment.armeabi-v7a.ll
stderr | /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.26/tools/Darwin/binutils/bin/llc: error: /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.26/tools/Darwin/binutils/bin/llc: environment.armeabi-v7a.ll:593:7: error: expected value token
stderr | i32 −1, ; apk_fd
Xamarin.Android.Common.targets(1979, 3): [XA3006] Could not compile native assembly file: environment.x86_64.ll
stderr | /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.26/tools/Darwin/binutils/bin/llc: error: /usr/local/share/dotnet/packs/Microsoft.Android.Sdk.Darwin/33.0.26/tools/Darwin/binutils/bin/llc: environment.x86_64.ll:593:7: error: expected value token
stderr | i32 −1, ; apk_fd
Activity
dellis1972 commentedon Apr 6, 2023
@grendello any ideas on this one?
grendello commentedon Apr 6, 2023
This code is generated when assembly stores are disabled (
$(AndroidUseAssemblyStore)=False), but I've just tested it locally and it builds fine with XA/main. @mrhenkiz can you please attach the whole project directory after build (that is withbin,obj, sources etc)?grendello commentedon Apr 6, 2023
Fragment of code generated locally when assembly stores are disabled:
It's an array of such entries, the fragment in the error message in OP isn't sufficient to say what
llcdoesn't like.mrhenkiz commentedon Apr 6, 2023
@grendello Thanks for the quick response. The zipfile is 26mb and I'm only allowed to upload 25mb. Is there any folders that i can skip to make the file smaller ?
EDIT: Uploaded it to file.io
Link
grendello commentedon Apr 6, 2023
I can confirm that the ll files in the provided sample fail to build, even though the code between my local test and them is nearly identical (the only difference is buffer size):
Local:
Example app:
Syntactically they're identical, so it must be something else in the file throwing llc off. Fascinating.
grendello commentedon Apr 6, 2023
If I manually change
-1to0then it works. Baffling :)mrhenkiz commentedon Apr 6, 2023
@grendello I don't know if it helps. But the errors for environment is randomly between every build. Sometimes it only complains about ie. environment.arm64-v8a.ll and other builds it complains about one or more. :)
grendello commentedon Apr 6, 2023
@mrhenkiz I suspect there's some earlier bit of code that is somehow corrupted (perhaps a filesystem issue, hard to tell). I'll investigate later today and will try to reproduce locally using your sample.
mrhenkiz commentedon Apr 6, 2023
@grendello Great, thanks. I can also say that i get same errors on a wiped intel mac where I only installed vs 2022 17.5.3 and created a project from the template (same versions as on the M1) and built.
8 remaining items
grendello commentedon Apr 6, 2023
FYI, these cultures also use the same minus sign and will be affected by this bug:
grendello commentedon Apr 6, 2023
If you build from command line, you can just do:
grendello commentedon Apr 6, 2023
@mrhenkiz you can put
export LANG=en_US.UTF-8in the
.profilefile in your home directory, then that value ofLANGwill be used for all terminal sessions. For GUI apps you'd either have to use thedefaultsutility (from terminal, dodefaults read | lessto see all the settings) or change the language in the macOS settings app.mrhenkiz commentedon Apr 6, 2023
@grendello Thank you. It worked like a charm when I added it to .zshrc :) Great job!
Fix integer to string conversion when generating code
PRMrainbow commentedon Apr 13, 2023
How can I change LANG in Windows?
mrhenkiz commentedon Apr 13, 2023
https://answers.microsoft.com/en-us/surface/forum/all/how-to-change-system-locale-in-windows-10-the/d7826ef0-13cd-43ea-8e01-2846d813dfed
PRMrainbow commentedon Apr 13, 2023
I have same error after changing system language from zh-TW to en-US.
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.26\tools\Xamarin.Android.Common.targets(1979,3): error XA3006: Could not compile native assembly file: typemaps.arm64-v8a.ll
grendello commentedon Apr 13, 2023
@PRMrainbow are you absolutely sure it's the same error? The
zh-TWculture appears to use the ASCII hyphen as the minus character. Can you build your app from command line with:dotnet build -c Release -bl dotnet msbuild -v:diag msbuild.binlog > msbuild.txtand then locate the string
error XA3006:inmsbuild.txtto see what the actual error is (it will be somewhere above the error line, might be mixed up with other lines if parallel build is in effect)PRMrainbow commentedon Apr 13, 2023
Well... It was built successfully with 'dotnet build -c Release -bl' while building in Visual Studio IDE it failed. So I can't get an error in msbuild.txt.
grendello commentedon Apr 14, 2023
@PRMrainbow then it's unlikely to be the same issue. However, maybe you'll get more info if you enable diagnostic MSBuild messages inside the IDE and hunt for the error in the output buffer after the build fails there.
[Xamarin.Android.Build.Tasks] Fix `-int.ToString()` for locales (#7941)
[Xamarin.Android.Build.Tasks] Fix `-int.ToString()` for locales (#7941)