question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android Release mode build doesn't work

See original GitHub issue

Description

Hello, after upgrade to the newest version I’m unable to build android app in release mode. I can’t publish repo of this app, what can I do now?

Build fails with errors:

Błąd NETSDK1144 Optymalizacja zestawów pod kątem rozmiaru nie powiodła się. Optymalizacja może zostać wyłączona przez ustawienie właściwości PublishTrimmed na wartość false. DA C:\Program Files\dotnet\sdk\7.0.100\Sdks\Microsoft.NET.ILLink.Tasks\build\Microsoft.NET.ILLink.targets 86

and:

Błąd IL1011 Failed to write 'obj\Release\net7.0-android\android-x86\linked\SkiaSharp.Views.Android.dll'. DA C:\Users\**\source\repos\DA\ILLink 1

Steps to Reproduce

  1. Build app in release mode

Link to public reproduction project repository

I cant publish this repo

Version with bug

7.0 (current)

Last version that worked well

6.0.424

Affected platforms

Android

Affected platform versions

Android all

Did you find any workaround?

No response

Relevant log output

1>ILLink : error IL1011: Failed to write 'obj\Release\net7.0-android\android-arm64\linked\SkiaSharp.Views.Android.dll'.
1>Fatal error in IL Linker
1>Unhandled exception. Mono.Linker.LinkerFatalErrorException: ILLink: error IL1011: Failed to write 'obj\Release\net7.0-android\android-arm64\linked\SkiaSharp.Views.Android.dll'.
1> ---> System.ArgumentException: Member 'System.Int32 SKCanvasView_ignorePixelScaling' is declared in another module and needs to be imported
1>   at Mono.Cecil.MetadataBuilder.LookupToken(IMetadataTokenProvider provider)
1>   at Mono.Cecil.Cil.CodeWriter.WriteOperand(Instruction instruction)
1>   at Mono.Cecil.Cil.CodeWriter.WriteInstructions()
1>   at Mono.Cecil.Cil.CodeWriter.WriteResolvedMethodBody(MethodDefinition method)
1>   at Mono.Cecil.Cil.CodeWriter.WriteMethodBody(MethodDefinition method)
1>   at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
1>   at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
1>   at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
1>   at Mono.Cecil.MetadataBuilder.AddTypes()
1>   at Mono.Cecil.MetadataBuilder.BuildTypes()
1>   at Mono.Cecil.MetadataBuilder.BuildModule()
1>   at Mono.Cecil.MetadataBuilder.BuildMetadata()
1>   at Mono.Cecil.ModuleWriter.<>c.<BuildMetadata>b__2_0(MetadataBuilder builder, MetadataReader _)
1>   at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
1>   at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
1>   at Mono.Cecil.ModuleWriter.Write(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
1>   at Mono.Cecil.ModuleWriter.WriteModule(ModuleDefinition module, Disposable`1 stream, WriterParameters parameters)
1>   at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
1>   at Mono.Cecil.AssemblyDefinition.Write(String fileName, WriterParameters parameters)
1>   at Mono.Linker.Steps.OutputStep.WriteAssembly(AssemblyDefinition assembly, String directory, WriterParameters writerParameters)
1>   --- End of inner exception stack trace ---
1>   at Mono.Linker.Steps.OutputStep.WriteAssembly(AssemblyDefinition assembly, String directory, WriterParameters writerParameters)
1>   at Mono.Linker.Steps.OutputStep.WriteAssembly(AssemblyDefinition assembly, String directory)
1>   at Mono.Linker.Steps.OutputStep.OutputAssembly(AssemblyDefinition assembly)
1>   at Mono.Linker.Steps.OutputStep.ProcessAssembly(AssemblyDefinition assembly)
1>   at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
1>   at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
1>   at Mono.Linker.Pipeline.Process(LinkContext context)
1>   at Mono.Linker.Driver.Run(ILogger customLogger)
1>   at Mono.Linker.Driver.Main(String[] args)

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:29 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
bradencohencommented, Dec 13, 2022

OK, based on some further testing and checking binlogs, we have confirmed it was the new linker step that was added in GA. This was disabled for the upcoming service release in #11096 as a result of #11069.

The solution for now is to use this in your csproj:

<AndroidLinkResources>false</AndroidLinkResources>

The next servicing release of .NET MAUI will have this disabled already.

Will this always need to be disabled? It makes the building process take 5x the time it used to.

1reaction
mattleibowcommented, Dec 9, 2022

This should fix it:

<AndroidLinkResources>false</AndroidLinkResources>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Release build of application is not working - android
I'm having a problem with my android project. It appears to work good in debug mode, but it crashes in release mode.
Read more >
App doesn't work in release apk but works fine in debug ...
First clean the android project, then keep running yarn react-native run-android —variant=release until the app launches without crashing.
Read more >
Prepare your app for release | Android Studio
Learn how to build a signed, release-ready APK. This process is the same for all Android apps.
Read more >
App works in debug mode but not Build Release App
When I compile my app in debug mode it runs just fine. When I compile using Build Release App it starts but then...
Read more >
Application not working in release mode(in production) on ...
Hello, I am facing a problem with my native android application. Everything works fine when I am testing my app through local build...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found