You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[NativeAOT] export for android cannot work #109713
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;
The failure mode you're seeing should only be reachable if someone turned on the unsupported IlcDisableReflection property. Make sure your project doesn't specify this anywhere.
You should be able to debug this same way as debugging a C++ library from Android Studio.
You might want to publish with symbol stripping turned off to make sure the debugger can find the debugging symbols. Pass -p:StripSymbols=false to dotnet publish and try debugging again with the new library.
The failure mode you're seeing should only be reachable if someone turned on the unsupported IlcDisableReflection property. Make sure your project doesn't specify this anywhere.
You should be able to debug this same way as debugging a C++ library from Android Studio.
You might want to publish with symbol stripping turned off to make sure the debugger can find the debugging symbols. Pass -p:StripSymbols=false to dotnet publish and try debugging again with the new library.
thanks for you reply,i set IlcDisableReflection forcr to false in csproj file and than enum and type can work now,thank you very much!
Wow, you literally set IlcDisableReflection to true in the <!-- From smolsharp section. Please do not use switches you don't understand or at least remember you set them.
but is it still cannot debug the NET code form android studio,i follow this guide
Those instructions are for mono. Can you try building an add method in C and stepping into that? With StripSymbols=false, stepping into C# should be no different from stepping into C. I don't know Android studio, sorry.
Wow, you literally set IlcDisableReflection to true in the <!-- From smolsharp section. Please do not use switches you don't understand or at least remember you set them.
but is it still cannot debug the NET code form android studio,i follow this guide
Those instructions are for mono. Can you try building an add method in C and stepping into that? With StripSymbols=false, stepping into C# should be no different from stepping into C. I don't know Android studio, sorry.
oh,it is my mistake,i cannot find the IlcDisableReflection is set in csproj file,sorry.
for debug net code from AS,I will try again,thanks!
Activity
MichalStrehovsky commentedon Nov 12, 2024
Did you specify IlcDisableReflection property?
[-]export for android cannot work[/-][+][NativeAOT] export for android cannot work[/+]llzz19851985 commentedon Nov 13, 2024
excuse me ,how to add this property?
MichalStrehovsky commentedon Nov 13, 2024
The failure mode you're seeing should only be reachable if someone turned on the unsupported
IlcDisableReflectionproperty. Make sure your project doesn't specify this anywhere.You should be able to debug this same way as debugging a C++ library from Android Studio.
You might want to publish with symbol stripping turned off to make sure the debugger can find the debugging symbols. Pass
-p:StripSymbols=falseto dotnet publish and try debugging again with the new library.llzz19851985 commentedon Nov 13, 2024
thanks for you reply,i set IlcDisableReflection forcr to false in csproj file and than enum and type can work now,thank you very much!

but is it still cannot debug the NET code form android studio,i follow this guide https://github.com/dotnet/runtime/blob/main/docs/workflow/debugging/mono/android-debugging.md,but not work,is there are some guide document?
MichalStrehovsky commentedon Nov 13, 2024
Wow, you literally set IlcDisableReflection to true in the
<!-- From smolsharpsection. Please do not use switches you don't understand or at least remember you set them.Those instructions are for mono. Can you try building an
addmethod in C and stepping into that? WithStripSymbols=false, stepping into C# should be no different from stepping into C. I don't know Android studio, sorry.llzz19851985 commentedon Nov 14, 2024
oh,it is my mistake,i cannot find the IlcDisableReflection is set in csproj file,sorry.
for debug net code from AS,I will try again,thanks!