Skip to content

Can't build .NET 7 android projects #7939

Closed

Description

@mrhenkiz

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

  1. added
    Area: App+Library BuildIssues when building Library projects or Application projects.
    needs-triageIssues that need to be assigned.
    on Apr 6, 2023
  2. dellis1972 commented on Apr 6, 2023

    @dellis1972
    Contributor

    @grendello any ideas on this one?

  3. grendello commented on Apr 6, 2023

    @grendello
    Contributor

    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 with bin, obj, sources etc)?

  4. grendello commented on Apr 6, 2023

    @grendello
    Contributor

    Fragment of code generated locally when assembly stores are disabled:

    ; Bundled assembly name buffers, all 70 bytes long
    @bundled_assemblies = local_unnamed_addr global [154 x %struct.XamarinAndroidBundledAssembly] [
            ; 0
            %struct.XamarinAndroidBundledAssembly {
                    i32 -1, ; apk_fd
                    i32 0, ; data_offset
                    i32 0, ; data_size
                    i8* null, ; data
                    i32 70, ; name_length
                    i8* getelementptr inbounds ([70 x i8], [70 x i8]* @__XamarinAndroidBundledAssembly_name_0, i32 0, i32 0); name
            }, 
    

    It's an array of such entries, the fragment in the error message in OP isn't sufficient to say what llc doesn't like.

  5. mrhenkiz commented on Apr 6, 2023

    @mrhenkiz
    Author

    @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

  6. grendello commented on Apr 6, 2023

    @grendello
    Contributor

    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:

    ; Bundled assembly name buffers, all 70 bytes long
    @bundled_assemblies = local_unnamed_addr global [154 x %struct.XamarinAndroidBundledAssembly] [
            ; 0
            %struct.XamarinAndroidBundledAssembly {
                    i32 -1, ; apk_fd
                    i32 0, ; data_offset
                    i32 0, ; data_size
                    i8* null, ; data
                    i32 70, ; name_length
                    i8* getelementptr inbounds ([70 x i8], [70 x i8]* @__XamarinAndroidBundledAssembly_name_0, i32 0, i32 0); name
            }, 
    

    Example app:

    ; Bundled assembly name buffers, all 66 bytes long
    @bundled_assemblies = local_unnamed_addr global [211 x %struct.XamarinAndroidBundledAssembly] [
            ; 0
            %struct.XamarinAndroidBundledAssembly {
                    i32 −1, ; apk_fd
                    i32 0, ; data_offset
                    i32 0, ; data_size
                    i8* null, ; data
                    i32 66, ; name_length
                    i8* getelementptr inbounds ([66 x i8], [66 x i8]* @__XamarinAndroidBundledAssembly_name_0, i32 0, i32 0); name
            }, 
    

    Syntactically they're identical, so it must be something else in the file throwing llc off. Fascinating.

  7. grendello commented on Apr 6, 2023

    @grendello
    Contributor

    If I manually change -1 to 0 then it works. Baffling :)

  8. mrhenkiz commented on Apr 6, 2023

    @mrhenkiz
    Author

    @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. :)

  9. grendello commented on Apr 6, 2023

    @grendello
    Contributor

    @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.

  10. mrhenkiz commented on Apr 6, 2023

    @mrhenkiz
    Author

    @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.

  11. 8 remaining items

  12. grendello commented on Apr 6, 2023

    @grendello
    Contributor

    FYI, these cultures also use the same minus sign and will be affected by this bug:

    et
    et-EE
    eu
    eu-ES
    fi
    fi-FI
    fo
    fo-DK
    fo-FO
    gsw
    gsw-CH
    gsw-FR
    gsw-LI
    hr
    hr-BA
    hr-HR
    ksh
    ksh-DE
    lt
    lt-LT
    nb
    nb-NO
    nb-SJ
    nn
    nn-NO
    no
    rm
    rm-CH
    se
    se-FI
    se-NO
    se-SE
    sl
    sl-SI
    sv
    sv-AX
    sv-FI
    sv-SE
    
  13. grendello commented on Apr 6, 2023

    @grendello
    Contributor

    Thanks for quick response @grendello. @rhult Did you confirm that it's working if you change LANG ? Where to change the lang in macos?

    If you build from command line, you can just do:

    $ LANG=en_US.UTF-8 dotnet build [...]
  14. grendello commented on Apr 6, 2023

    @grendello
    Contributor

    @mrhenkiz you can put

    export LANG=en_US.UTF-8

    in the .profile file in your home directory, then that value of LANG will be used for all terminal sessions. For GUI apps you'd either have to use the defaults utility (from terminal, do defaults read | less to see all the settings) or change the language in the macOS settings app.

  15. mrhenkiz commented on Apr 6, 2023

    @mrhenkiz
    Author

    @grendello Thank you. It worked like a charm when I added it to .zshrc :) Great job!

  16. PRMrainbow commented on Apr 13, 2023

    @PRMrainbow

    How can I change LANG in Windows?

  17. PRMrainbow commented on Apr 13, 2023

    @PRMrainbow

    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

  18. grendello commented on Apr 13, 2023

    @grendello
    Contributor

    @PRMrainbow are you absolutely sure it's the same error? The zh-TW culture 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.txt

    and then locate the string error XA3006: in msbuild.txt to 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)

  19. PRMrainbow commented on Apr 13, 2023

    @PRMrainbow

    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.

  20. grendello commented on Apr 14, 2023

    @grendello
    Contributor

    @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.

  21. ghost locked as resolved and limited conversation to collaborators on May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions