0

I've an Android app that compiles and runs in Debug mode. When I set it to Release mode, I receive following error during compilation:

    XALNK7001: System.NullReferenceException: Object reference not set to an instance of an object.
   at MonoDroid.Tuner.AddKeepAlivesStep.AddKeepAlives(TypeDefinition type)
   at MonoDroid.Tuner.AddKeepAlivesStep.AddKeepAlives(AssemblyDefinition assembly)
   at MonoDroid.Tuner.AddKeepAlivesStep.ProcessAssembly(AssemblyDefinition assembly)
   at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
   at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
   at Mono.Linker.Pipeline.Process(LinkContext context)
   at MonoDroid.Tuner.Linker.Process(LinkerOptions options, ILogger logger, LinkContext& context)
   at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)
   at Xamarin.Android.Tasks.LinkAssemblies.RunTask()
   at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 17 Jokes.Droid             

Can anyone help me? What could be the reason of this error?

Below Release configs enter image description here

Below Debug configs enter image description here

Badozvora
  • 383
  • 1
  • 3
  • 15
  • For the introduction of System.NullReferenceException errors and related solutions, you can refer to the website:”https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it“. And If you can, you may provide more code about MonoDroid.Tuner.AddKeepAlivesStep.AddKeepAlives. – Hongxin Sui-MSFT Sep 26 '22 at 08:33
  • Hi, thanks for your answer. I know the general meaning of NullReferenceExceptions but this error means that there's an error into a Microsoft Framewrok's class "Microsoft.Android.Build.BaseTasks/AndroidTask.cs" at line 17. But the strange thing is that in debug mode the application compiles correctly. – Badozvora Sep 26 '22 at 14:50
  • You may update all dependencies. By the way, may I know if you have used Linker on a Debug build? – Hongxin Sui-MSFT Sep 27 '22 at 02:09
  • Hi @HongxinSui-MSFT I edited my post adding Release and Debug configs screenshots. So you can check all configs and tell me if something is wrong. All nuget packages are up to date. Thanks – Badozvora Sep 29 '22 at 09:56
  • You may check the "use incremental Android system (aapt2)" in Release configuration. – Hongxin Sui-MSFT Sep 30 '22 at 05:16

0 Answers0