Repository navigation
Open
Labels
Area: App RuntimeIssues in `libmonodroid.so`.need-attentionA xamarin-android contributor needs to review
Milestone
Description
Android framework version
net10.0-android
Affected platform version
Workload 10.0.103
Description
Our Android app using NativeAOT crashes on startup when built with workload 10.0.103. The same app builds and runs correctly with workload 10.0.102. No code changes between the two builds.
Stacktrace:
Exception java.lang.UnsatisfiedLinkError:
at java.lang.Runtime.loadLibrary0 (Runtime.java:1097)
at java.lang.Runtime.loadLibrary0 (Runtime.java:1019)
at java.lang.System.loadLibrary (System.java:1765)
at net.dot.jni.nativeaot.JavaInteropRuntime.<clinit> (JavaInteropRuntime.java:8)
at net.dot.jni.nativeaot.NativeAotRuntimeProvider.attachInfo (NativeAotRuntimeProvider.java:38)
at android.app.ActivityThread.installProvider (ActivityThread.java:9021)
at android.app.ActivityThread.installContentProviders (ActivityThread.java:8536)
at android.app.ActivityThread.handleBindApplication (ActivityThread.java:8191)
at android.app.ActivityThread.-$$Nest$mhandleBindApplication (Unknown Source)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2642)
at android.os.Handler.dispatchMessage (Handler.java:107)
at android.os.Looper.loopOnce (Looper.java:282)
at android.os.Looper.loop (Looper.java:387)
at android.app.ActivityThread.main (ActivityThread.java:9500)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:600)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1005)
I have only tested our app with this.
I haven't been able to try 11.0.100-preview.1 owing to an issue with the UseDotNet@2 task and preview sdks.
Steps to Reproduce
I have only tested our app with this.
Project configuration:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0-android</TargetFramework>
<OutputType>Exe</OutputType>
<RootNamespace>...</RootNamespace>
<AssemblyName>...</AssemblyName>
<SupportedOSPlatformVersion>26.0</SupportedOSPlatformVersion>
<RuntimeIdentifiers>android-x64;android-arm64</RuntimeIdentifiers>
<AndroidPackageFormats>aab</AndroidPackageFormats>
<UseMauiEssentials>true</UseMauiEssentials>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<PublishAot>true</PublishAot>
<AndroidLinkTool>r8</AndroidLinkTool>
</PropertyGroup>
Did you find any workaround?
Pin maui-android workload to 10.0.102
Relevant log output
Reacted by Betta_Fish
Reacted by Copilot
Metadata
Metadata
Assignees
Labels
Area: App RuntimeIssues in `libmonodroid.so`.need-attentionA xamarin-android contributor needs to review
Activity
jonathanpeppers commentedon Feb 17, 2026
I don't see a commit related to NativeAOT in this range:
We did improve some things in main, @grendello is there a fix related to NativeAOT we should backport?
Fix NativeAOT Android app crash with UnsatisfiedLinkError
grendello commentedon Feb 18, 2026
I would need to see the logcat output for this error first. @charlesroddie can you send us logcat output from around the crash? You can use these commands from the terminal:
jonathanpeppers commentedon Feb 18, 2026
Copilot found a change in dotnet/runtime that might cause it, does setting
_UseNativeLibPrefix=truein the.csprojhelp any?_UseNativeLibPrefix=trueto fix UnsatisfiedLinkError on Android #10825charlesroddie commentedon Feb 18, 2026
I got a good build with
_UseNativeLibPrefix=trueand 10.0.103 so that's very promising.jonathanpeppers commentedon Feb 18, 2026
So, I think what happened is a change in dotnet/runtime dropped the
libprefix from the.sofile name -- unless you set this property.I'll update our release branch to see if a new runtime fails.
sbomer commentedon Feb 19, 2026
Do we know why this only showed up in a servicing update? Does main have a different solution?
jonathanpeppers commentedon Feb 19, 2026
@sbomer I tried updating various .NET SDK releases:
But none of them seem to include the runtime with this issue.
jonathanpeppers commentedon Feb 19, 2026
Ok, I found a problem with how codeflow is working in .NET 10 servicing:
I suspect NativeAOT will fail, and I can work on the fix here in #10845.
charlesroddie commentedon Feb 27, 2026
This is very puzzling. I did get a working build at least once by setting the workload to 10.0.102. And I got a working build at least once by setting
_UseNativeLibPrefix=true. But these fixes haven't lasted and the same code produces non-working builds now. Attempts to get completely clean builds with nuget cache clears etc. have not changed this.To diagnose the
libprefix I added this to the ci yml:And the output is:
So everything has
lib. This is both with and without_UseNativeLibPrefix. So perhaps_UseNativeLibPrefixis not relevant.Updating the build agent from VS18.0.2 to 18.3.2 has given me another good build.
zxbmmmmmmmmm commentedon Mar 12, 2026
same problem, and using
_UseNativeLibPrefixcan't solve this.charlesroddie commentedon Mar 12, 2026
@zxbmmmmmmmmm are you on latest visual studio? Updating VS on our build agent (even though the pipeline doesn't mention VS explicitly) seems to have resolved the problem. I'm not 100% sure as some previous attempts (including pinning to older worloads, using
_UseNativeLibPrefixseemed to help but only momentarily. The VS update is still working after 2 weeks so better than the other attempts for us.zxbmmmmmmmmm commentedon Mar 12, 2026
I'm using latest VS Insiders [11605.296]
charlesroddie commentedon Mar 12, 2026
@grendello asked for logcat output earlier and I haven't got round to getting that yet. I think that's the next step for this issue. If you can get one @zxbmmmmmmmmm it would progress things.
NativeAOT: Use `lib` prefix by default on Unix for native library out…
charlesroddie commentedon Apr 6, 2026
We got a logcat. The relevant part:
charlesroddie commentedon Apr 10, 2026
I assume a workaround will be to use
<RuntimeIdentifiers>android-arm64</RuntimeIdentifiers>only on release builds. We had<RuntimeIdentifiers>android-x64;android-arm64</RuntimeIdentifiers>which is still the default. Claude thought that contamination might have occured from previous x64 builds being picked up by mistake in an incremental build system: that sounds plausible.