maui: Building untrimmed application on Android on Release ends with Exception 'Unable to find Java.Lang.AbstractMethodError constructor'

#6569 Issue still exists in

  • MAUI Blazor RC3,
  • Visual Studio Version 17.3.0 Preview 1.0.
  • Android 11 (API 30) image

Attaching sample project here MauiSqliteErrorSample.zip

Some Background:

_Originally posted by @soundaranbu in https://github.com/dotnet/maui/issues/6569#issuecomment-1128381993_

(Recreating as the original issue was closed)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 3
  • Comments: 32 (12 by maintainers)

Most upvoted comments

Can confirm this is still a thing, its a bit disheartening considering how old this issue is… Has anyone found a workaround? Entity Framework is not trimming compatible (yet), trimming deletes essential code. Untrimmed release config won’t build, so its a bit of a dead end 😦

This is still an issue as of VS 17.3.6, .NET6 (6.0.402) and: “Microsoft.EntityFrameworkCore” Version=“6.0.10” “Microsoft.EntityFrameworkCore.Abstractions” Version=“6.0.10” “Microsoft.EntityFrameworkCore.Analyzers” Version=“6.0.10” “Microsoft.EntityFrameworkCore.Relational” Version=“6.0.10” “Microsoft.EntityFrameworkCore.SqlServer” Version=“6.0.10”

I would like to add that apps built in debug mode, work flawlessly.

You can get a binlog from Visual Studio with the Project System Tools Extension.

That would be helpful.

I’m away and awaiting the logs from my end will only prolong the fix.

The repro steps in #14605 are straight forward and quite simple to try. But it has to be tried exactly as it is (No CLI). If it’s not reproducible, then I’m more than happy to try & provide the required VS logs.

If it’s not possible from my side, then @rbrettj may also help.

Thanks for all the hard work you people are putting in.

@jonathanpeppers The info that you are asking is for a runtime crash? But this is rather a build time error in VS after adding the property PublishTrimmed false. Repro steps here #14605 As many people confirmed, this still seems to an issue in .NET 7. (Please try the repo steps in #14605). An existing project will normally compile fine.

This property need not be added to a new project. One may add it much later(like me) when they try to publish the app in Release mode and find that some of the libraries are not trim compatible. I guess this is a most common scenario where many people will come across and it gives a bad user experience. That’s my humble opinion.

By the way, thanks for suggesting the better approach. I’ll give it a shot whenever I get time. But I’m afraid that the original issue is still intact.

The reason is that not all the libraries are trim compatible. In my case, I had no other option other than to set the PublishTrimmed to false to use the libraries in Release mode.

I think a better solution here is to exclude a single assembly instead of turning off trimming entirely, something like:

<ItemGroup>
  <TrimmerRootAssembly Include="MyAssembly" />
</ItemGroup>

https://learn.microsoft.com/dotnet/core/deploying/trimming/trimming-options

Otherwise your app could be 100 MB or so? As it will include all of the BCL.

What we’re looking for here is a stack trace/log if anyone is still hitting this issue in .NET 7. Instructions at: https://github.com/dotnet/maui/issues/7284#issuecomment-1511383946

Hi @jonathanpeppers, sorry I was away for sometime.

The reason is that not all the libraries are trim compatible. In my case, I had no other option other than to set the PublishTrimmed to false to use the libraries in Release mode.

What info do you need exactly? Why I’m disabling trimming is irrelevant. It is a feature and thus should work correctly regardless. The issue isn’t my code since it fails with File -> New MAUI project. This should be something easily reproduceable.