Skip to content

[NativeAOT] export for android cannot work #109713

@llzz19851985

Description

@llzz19851985

Description

Based on the Android-NativeAOT , I wrote a simple example for exporting a dynamic link library to Android studio called by java,the all code as follow:
`
namespace libdotnet
{
// dotnet build
// dotnet publish -r linux-bionic-arm64 -p:DisableUnsupportedError=true
// echo $Env:ANDROID_NDK_HOME

public enum EnumXX
{
    Common,
    Hello,
    World
};

public class VAotApi
{
    [UnmanagedCallersOnly(EntryPoint = "add")]
    public static int Add(int a, int b)
    {
        Log.Info($"=======================Call add method A34:{EnumXX.Common.ToString()}");
        Type tyx = typeof(EnumXX);
        string name = tyx.Name;
        Log.Info($"=======================Call add method :{name}");
        
        return 100 + a + b;
    }

}

}
`

when use the published shared library ,the following problem occurred:
1)it cannot access System.Type properties such as Name,when access,it crash directly;
2)Enum all converted to int,cannot get the Enum string by Enum.ToString();
3)Is there a way to debug into the NET code from android studio?

Reproduction Steps

use command 'dotnet publish -r linux-bionic-arm64 -p:DisableUnsupportedError=true' to export and import into android project

Expected behavior

1)can access System.Type properties
2)can get Enum string by Enum.Tostring() method;
3)can debug the NET code from android studio;

Actual behavior

1)it cannot access System.Type properties such as Name,when access,it crash directly;
2)Enum all converted to int,cannot get the Enum string by Enum.ToString();
3)cannot debug into the NET code from android studio;

Regression?

No response

Known Workarounds

No response

Configuration

net8.0
android ndk R23
Visual studio 2022 17.11.5

dotnet --list-sdks
2.1.202 [C:\Program Files\dotnet\sdk]
2.1.526 [C:\Program Files\dotnet\sdk]
5.0.409 [C:\Program Files\dotnet\sdk]
8.0.403 [C:\Program Files\dotnet\sdk]

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions