Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot publish android project with ReadyToRun #109004

Open
MaxwellDAssistek opened this issue Oct 18, 2024 · 4 comments
Open

Cannot publish android project with ReadyToRun #109004

MaxwellDAssistek opened this issue Oct 18, 2024 · 4 comments
Labels
area-ReadyToRun-coreclr os-android untriaged New issue has not been triaged by the area owner

Comments

@MaxwellDAssistek
Copy link

Description

When I attempt to publish an Android project (with or without MAUI) using ReadyToRun, I get an exception while building.

Reproduction Steps

  1. Create a new Android app project.
  2. Add the following to the csproj file:
    <RunAOTCompilation>false</RunAOTCompilation>
    <PublishTrimmed>false</PublishTrimmed>
    <PublishReadyToRun>true</PublishReadyToRun>
  1. Run the following command: dotnet publish -f net8.0-android -c Release -p:RuntimeIdentifier=android-arm64

Expected behavior

Publish should complete successfully.

Actual behavior

MSBuild version 17.9.8+b34f75857 for .NET
  Determining projects to restore...
  Restored <snip>\AndroidApp1\AndroidApp1\AndroidApp1.csproj (in 279 ms).
  AndroidApp1 -> <snip>\AndroidApp1\AndroidApp1\bin\Release\net8.0-android\android-arm64\  AndroidApp1.dll
C:\Program Files\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(470,5): error : Error: Object reference not set to an instance of an object. [<snip>\AndroidApp1\AndroidApp 1\AndroidApp1.csproj]
C:\Program Files\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(470,5): error : System.NullReferenceException: Object reference not set to an instance of an object. [<snip>\AndroidApp1\AndroidApp1\AndroidApp1.csproj]
C:\Program Files\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(470,5): error :     at ILCompiler.ProcessLinkerXmlBase.ProcessXml(Boolean) + 0xd9 [<snip>\AndroidApp1\AndroidApp1\AndroidApp1.csproj]
C:\Program Files\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(470,5): error :     at ILCompiler.Compilation..ctor(DependencyAnalyzerBase`1, NodeFactory, IEnumerable`1, ILProvider, DevirtualizationManager, IEnumerable`1, Logger, InstructionSetSupport) + 0x143 [<snip>\AndroidApp1\AndroidApp1\AndroidApp1.csproj]
C:\Program Files\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(470,5): error :     at ILCompiler.ReadyToRunCodegenCompilation..ctor(DependencyAnalyzerBase`1, NodeFactory, IEnumerable`1, ILProvider, Logger, DevirtualizationManager, IEnumerable`1, String, InstructionSetSupport, Boolean, Boolean, Boolean, Boolean, Func`2, String, Boolean, String, Int32, Boolean, Int32, ProfileDataManager, ReadyToRunMethodLayoutAlgorithm, ReadyToRunFileLayoutAlgorithm, Int32, Boolean) + 0x1b5 [<snip>\AndroidApp1\AndroidApp1\AndroidApp 
1.csproj]
C:\Program Files\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(470,5): error :     at ILCompiler.ReadyToRunCodegenCompilationBuilder.ToCompilation() + 0x6ac [<snip>\AndroidApp1\AndroidApp1\AndroidApp1.csproj]
C:\Program Files\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(470,5): error :     at ILCompiler.Program.RunSingleCompilation(Dictionary`2, InstructionSetSupport, String, Dictionary`2, HashSet`1, ReadyToRunCompilerContext, Logger) + 0x1d23 [<snip>\AndroidApp1\AndroidApp1\AndroidApp1.csproj]
C:\Program Files\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(470,5): error :     at ILCompiler.Program.Run() + 0x11c6 [<snip>\AndroidApp1\AndroidApp1\AndroidApp1.csproj] 
C:\Program Files\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(470,5): error :     at ILCompiler.Crossgen2RootCommand.<>c__DisplayClass205_0.<.ctor>b__0(ParseResult result) + 0x3e9 [<snip>\AndroidApp1\AndroidApp1\AndroidApp1.csproj]
C:\Program Files\dotnet\sdk\8.0.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.CrossGen.targets(358,5): error NETSDK1096: Optimizing assemblies for performance failed. You can either exclude the failing assemblies from being optimized, or set the PublishReadyToRun property to false. [<snip>\AndroidApp1\AndroidApp1\AndroidApp1.csproj]

Regression?

No response

Known Workarounds

No response

Configuration

.NET version 8.0.204
Windows 10

Other information

No response

@dotnet-issue-labeler dotnet-issue-labeler bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 18, 2024
@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Oct 18, 2024
Copy link
Contributor

Tagging subscribers to 'arch-android': @vitek-karas, @simonrozsival, @steveisok, @akoeplinger
See info in area-owners.md if you want to be subscribed.

@filipnavara
Copy link
Member

.NET on Android uses the MonoVM runtime. R2R is only available with CoreCLR runtime and it's thus NOT available on Android.

However, MonoVM does support ahead of time compilation and profiled AOT.

@MaxwellDAssistek
Copy link
Author

@filipnavara I am looking to dynamically load some plugins during runtime, which prevents using AOT, so I was attempting to use Ready To Run to optimize the first-load performance of these plugins.

@vcsjones vcsjones removed the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Oct 19, 2024
@filipnavara
Copy link
Member

@filipnavara I am looking to dynamically load some plugins during runtime, which prevents using AOT, so I was attempting to use Ready To Run to optimize the first-load performance of these plugins.

MonoVM AOT is technically closer to how CoreCLR ReadyToRun works. It still allows dynamic code. It's NOT the same as NativeAOT that has the restrictions you are mentioning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ReadyToRun-coreclr os-android untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

No branches or pull requests

4 participants