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

System.DllNotFoundException: libmono-native.so assembly:<unknown assembly> type:<unknown type> member:(null) #4772

Closed
todorspetkov opened this issue Jun 3, 2020 · 33 comments · Fixed by #4861
Assignees

Comments

@todorspetkov
Copy link

todorspetkov commented Jun 3, 2020

Description

Observing the following Exception in Firebase Crashlytics only on Android 5.0.x devices, 90% on Huawei devices. Release build (no shared mono runtime). Anyone seen somthething similar?

Fatal Exception: android.runtime.JavaProxyThrowable: System.DllNotFoundException: libmono-native.so assembly:<unknown assembly> type:<unknown type> member:(null)
  at (wrapper managed-to-native) Interop+Sys.GetNonCryptographicallySecureRandomBytes(byte*,int)
  at Interop.GetRandomBytes (System.Byte* buffer, System.Int32 length) [0x00000] in <1b7a5cd4b5194667aea235f87b2a861e>:0 
  at System.Guid.NewGuid () [0x00000] in <1b7a5cd4b5194667aea235f87b2a861e>:0 
  Comune.InitializeComponent () [0x00182] in <1170faa3308346b08cbc4f21dc5916bc>:0 
  at xxx.Views.SelezioneComune..ctor (System.Boolean isCambia) [0x0000c] in <1170faa3308346b08cbc4f21dc5916bc>:0 
  at xxx.App.OnStart () [0x000aa] in <1170faa3308346b08cbc4f21dc5916bc>:0 
  at Xamarin.Forms.Application.SendStart () [0x00000] in <9608dd67eb804f0494e04a66ff90c168>:0 
  at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnStateChanged () [0x0001b] in <63e7c9910ab446ac9b78b1ac3ac3e5bb>:0 
  at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnStart () [0x00046] in <63e7c9910ab446ac9b78b1ac3ac3e5bb>:0 
  at xxx.Droid.MainActivity.OnStart () [0x00000] in <db697bb0cebf40899ddd1dbba31ef430>:0 
  at Android.App.Activity.n_OnStart (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <26ea6ddb724e4be2b66b6bde37c83c15>:0 
  at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.14(intptr,intptr)
       at crc6473e84085518c5ff7.MainActivity.n_onStart(MainActivity.java)
       at crc6473e84085518c5ff7.MainActivity.onStart(MainActivity.java:85)
       at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1224)
       at android.app.Activity.performStart(Activity.java:6032)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2466)
       at android.app.ActivityThread.access$1200(ActivityThread.java:152)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:135)
       at android.app.ActivityThread.main(ActivityThread.java:5538)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

Basic Information

Minimum Android version : Android 5.0 (API level 21)
Target Android version : Android 10.0 (API level 29)
=== Visual Studio Community 2019 for Mac ===

Version 8.6.2 (build 6)
Installation UUID: 69833a91-0eac-4ae5-b6a6-d5db1c20fbb4
	GTK+ 2.24.23 (Raleigh theme)
	Xamarin.Mac 6.18.0.23 (d16-6 / 088c73638)

	Package version: 610000104

=== Mono Framework MDK ===

Runtime:
	Mono 6.10.0.104 (2019-12/5d03a6fe116) (64-bit)
	Package version: 610000104

=== Roslyn (Language Service) ===

3.6.0-3.20210.9+4eafdcb1bcbd8d3573f2ba6065e56d9b9ce4f8a3

=== NuGet ===

Version: 5.6.0.6591

=== .NET Core SDK ===

SDK: /usr/local/share/dotnet/sdk/3.1.300/Sdks
SDK Version: 3.1.300
MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/6.10.0/lib/mono/msbuild/Current/bin/Sdks

=== .NET Core Runtime ===

Runtime: /usr/local/share/dotnet/dotnet
Runtime Versions:
	3.1.4
	2.1.18

=== Xamarin.Profiler ===

Version: 1.6.15.68
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Updater ===

Version: 11

=== Xamarin.Android ===

Version: 10.3.1.4 (Visual Studio Community)
Commit: xamarin-android/d16-6/3a10de9
Android SDK: /Users/todor/Library/Android/sdk
	Supported Android versions:
		None installed

SDK Tools Version: 26.1.1
SDK Platform Tools Version: 30.0.1
SDK Build Tools Version: 30.0.0 rc4

Build Information: 
Mono: 165f4b0
Java.Interop: xamarin/java.interop/d16-6@2cab35c
ProGuard: xamarin/proguard/master@905836d
SQLite: xamarin/sqlite/3.31.1@49232bc
Xamarin.Android Tools: xamarin/xamarin-android-tools/d16-6@bfb66f3

=== Microsoft Mobile OpenJDK ===

Java SDK: /Users/todor/Library/Developer/Xamarin/jdk/microsoft_dist_openjdk_1.8.0.25
1.8.0-25
Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Android SDK Manager ===

Version: 16.6.0.50
Hash: 5901879
Branch: remotes/origin/d16-6
Build date: 2020-04-30 04:01:22 UTC

=== Android Device Manager ===

Version: 16.6.0.95
Hash: 45d17b5
Branch: remotes/origin/d16-6
Build date: 2020-04-30 04:01:42 UTC

=== Xamarin Designer ===

Version: 16.6.0.329
Hash: d4f8bcd13
Branch: remotes/origin/d16-6
Build date: 2020-04-24 02:16:02 UTC

=== Apple Developer Tools ===

Xcode 11.5 (16139)
Build 11E608c

=== Xamarin.Mac ===

Xamarin.Mac not installed. Can't find /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/Version.

=== Xamarin.iOS ===

Version: 13.18.2.1 (Visual Studio Community)
Hash: 29c4ea731
Branch: d16-6
Build date: 2020-05-26 17:03:05-0400

=== Build Information ===

Release ID: 806020006
Git revision: c742dc3fcbf76855738eef57ce41d65f91acbf27
Build date: 2020-05-28 15:22:51-04
Build branch: release-8.6
Xamarin extensions: c742dc3fcbf76855738eef57ce41d65f91acbf27

=== Operating System ===

Mac OS X 10.15.5
Darwin 19.5.0 Darwin Kernel Version 19.5.0
    Tue May 26 20:41:44 PDT 2020
    root:xnu-6153.121.2~2/RELEASE_X86_64 x86_64
@todorspetkov
Copy link
Author

Additional info: Compile Android Target Framework = Android 10.0 (Q).

@jsuarezruiz
Copy link

@samhouts Could we move this issue to https://github.com/xamarin/xamarin-android/issues and move forward to get more information?

@todorspetkov
Copy link
Author

todorspetkov commented Jun 5, 2020

Here is a full stack trace (logcat) from a Huawei P8 Lite Android API 21. This only happens on some Android API 21 devices.

06-05 05:54:53.935: I/MonoDroid(20521): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'PanCardView.Droid.CardsViewRenderer' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Random' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Sys' threw an exception. ---> System.DllNotFoundException: libmono-native.so assembly:<unknown assembly> type:<unknown type> member:(null)
06-05 05:54:53.935: I/MonoDroid(20521):   at (wrapper managed-to-native) Interop+Sys.LChflagsCanSetHiddenFlag()
06-05 05:54:53.935: I/MonoDroid(20521):   at Interop+Sys..cctor () [0x00000] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):    --- End of inner exception stack trace ---
06-05 05:54:53.935: I/MonoDroid(20521):   at System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath, System.Int32 fileType, Interop+ErrorInfo& errorInfo) [0x00007] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at System.IO.FileSystem.FileExists (System.ReadOnlySpan`1[T] fullPath) [0x00006] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at System.IO.File.Exists (System.String path) [0x00043] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.FileImageSourceHandler.LoadImageAsync (Xamarin.Forms.ImageSource imagesource, Android.Widget.ImageView imageView, System.Threading.CancellationToken cancellationToken) [0x0000c] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.ImageViewExtensions.UpdateBitmap (Android.Widget.ImageView imageView, Xamarin.Forms.IImageElement newView, Xamarin.Forms.IImageElement previousView, Xamarin.Forms.ImageSource newImageSource, Xamarin.Forms.ImageSource previousImageSource) [0x001bf] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Interop.GetRandomBytes (System.Byte* buffer, System.Int32 length) [0x00000] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at System.Random.GenerateGlobalSeed () [0x00000] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at System.Random..cctor () [0x00000] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):    --- End of inner exception stack trace ---
06-05 05:54:53.935: I/MonoDroid(20521):   at PanCardView.Droid.CardsViewRenderer..cctor () [0x00000] in <2c8a147a111949b3bd5c382644efebe0>:0 
06-05 05:54:53.935: I/MonoDroid(20521):    --- End of inner exception stack trace ---
06-05 05:54:53.935: I/MonoDroid(20521):   at (wrapper managed-to-native) System.Reflection.RuntimeConstructorInfo.InternalInvoke(System.Reflection.RuntimeConstructorInfo,object,object[],System.Exception&)
06-05 05:54:53.935: I/MonoDroid(20521):   at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x00005] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):    --- End of inner exception stack trace ---
06-05 05:54:53.935: I/MonoDroid(20521):   at System.Reflection.RuntimeConstructorInfo.InternalInvoke (System.Object obj, System.Object[] parameters, System.Boolean wrapExceptions) [0x0001d] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at System.Reflection.RuntimeConstructorInfo.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00086] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at System.Reflection.RuntimeConstructorInfo.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at System.RuntimeType.CreateInstanceImpl (System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes, System.Threading.StackCrawlMark& stackMark) [0x0022b] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at System.Activator.CreateInstance (System.Type type, System.Reflection.BindingFlags bindingAttr, System.Reflection.Binder binder, System.Object[] args, System.Globalization.CultureInfo culture, System.Object[] activationAttributes) [0x0009c] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at System.Activator.CreateInstance (System.Type type, System.Object[] args) [0x00000] in <96e786663b0547dda3a2b357695888ab>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Internals.DependencyResolver.ResolveOrCreate (System.Type type, System.Object source, System.Type visualType, System.Object[] args) [0x000af] in <1afe74fdb5894902ba3079cf55eb36e4>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Internals.Registrar`1[TRegistrable].GetHandler (System.Type type, System.Object source, Xamarin.Forms.IVisual visual, System.Object[] args) [0x00060] in <1afe74fdb5894902ba3079cf55eb36e4>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Internals.Registrar`1[TRegistrable].GetHandlerForObject[TOut] (System.Object obj, System.Object[] args) [0x00041] in <1afe74fdb5894902ba3079cf55eb36e4>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x00005] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000c4] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x0016c] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000dd] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000c4] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x0016c] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000dd] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000c4] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x0016c] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000dd] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000c4] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x0016c] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000dd] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x000c4] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x0016c] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000dd] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00033] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element, Android.Content.Context context) [0x0001f] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.AddChild (Xamarin.Forms.Page page, System.Boolean layout) [0x0000d] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPageInternal (Xamarin.Forms.Page newRoot) [0x00061] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.AppCompat.Platform.SetPage (Xamarin.Forms.Page newRoot) [0x000e6] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.InternalSetPage (Xamarin.Forms.Page page) [0x00020] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.SetMainPage () [0x0000c] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.AppOnPropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x00035] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.BindableObject.OnPropertyChanged (System.String propertyName) [0x00012] in <1afe74fdb5894902ba3079cf55eb36e4>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Element.OnPropertyChanged (System.String propertyName) [0x00000] in <1afe74fdb5894902ba3079cf55eb36e4>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Application.set_MainPage (Xamarin.Forms.Page value) [0x0008b] in <1afe74fdb5894902ba3079cf55eb36e4>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Junker.App.OnStart () [0x00065] in <07bcc23a4f5543bba50d8c5e8b514d6e>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Application.SendStart () [0x00000] in <1afe74fdb5894902ba3079cf55eb36e4>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnStateChanged () [0x0001b] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Xamarin.Forms.Platform.Android.FormsAppCompatActivity.OnStart () [0x00046] in <507a3bfe8d9744f7bb3ac35ad413a0b7>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Junker.Droid.MainActivity.OnStart () [0x00000] in <7005ba6e7a6b40dcaed5e603deb28a12>:0 
06-05 05:54:53.935: I/MonoDroid(20521):   at Android.App.Activity.n_OnStart (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <eaa205f580954a64824b74a79fa87c62>:0 

@samhouts samhouts transferred this issue from xamarin/Xamarin.Forms Jun 5, 2020
@radekdoulik radekdoulik added this to the Under Consideration milestone Jun 8, 2020
@grendello
Copy link
Contributor

@todorspetkov is libmono-native.so found in in the APK?

@grendello grendello added the need-info Issues that need more information from the author. label Jun 9, 2020
@todorspetkov
Copy link
Author

@todorspetkov is libmono-native.so found in in the APK?

Yes libmono-native.so is present. The apk works on all Android platforms > SDK 21.

@grendello
Copy link
Contributor

@todorspetkov I don't have enough information in the previous posts to be sure what's going on, but since it involves a native shared library, I guess that some of those devices lack some native symbols (for one reason or another) which prevents the native library from being loaded by the system. Note that the library is built by the Mono project with NDK against API 16 for 32-bit targets and against API 21 for 64-bit targets so it should work (and it does in a fair amount of tests both Mono and Xamarin.Android run). To further diagnose this, if you have access to a failing device, please follow these steps and post a full logcat record (please issue adb logcat -c before dumping the logcat buffer, it will minimise noise) here.

@grendello
Copy link
Contributor

Hm, actually, the steps I pointed out won't work... I've just noticed they're for Android O, Android 5.0 won't have the necessary support.

@grendello
Copy link
Contributor

However, please enable all the possible logging in your application by issuing the following commands from command line before starting your application:

adb shell setprop debug.mono.env "MONO_LOG_LEVEL=debug|MONO_LOG_MASK=dll"
adb shell setprop debug.mono.log default,assembly
adb logcat -c

Then make sure to cold start the application and when it crashes, back on the command line, issue

adb logcat -d > log.txt

And attach the log.txt file here, hopefully it will tell us something more

@todorspetkov
Copy link
Author

The error has been signaled by our users and I have seen it in firebase crashlytics. The stack traces I have included are from Firebase Robo device tests. I do not have a physical device with Android 5.0 where I can set adb shell properties... I will try to get one...

@grendello
Copy link
Contributor

@todorspetkov I doubt it's just any 5.0 device. Some manufacturers were known to make changes to Android that broke compatibility, but never wholesale, it was always per-model (or sometimes even per Android build)

@todorspetkov
Copy link
Author

Regarding this exception Firebase crashlytics says: 76% Huawei, 92% Android 5 devices... I was able to reproduce the crash in Firebase Test lab Robo on a Huawei P8 Lite API 21...

@grendello
Copy link
Contributor

@todorspetkov So it looks like some Huawei-specific change that broke things. Were you able to enable the extra logging on that device (if it is even possible using the test lab)?

@todorspetkov
Copy link
Author

I am not able to perform the adb shell operations you suggested in Test Lab. I will have to find a physical device thet crashes... It seems very hard these days to get your hands on a 2016 Huawei device running Android 5 :-).

@grendello
Copy link
Contributor

It is quite ancient, indeed... :) I'm afraid there's no other way though :(

@brendanzagaeski
Copy link
Contributor

brendanzagaeski commented Jun 10, 2020

By chance I was working today on a different issue that required additional logging, and for that issue I checked if it was possible to set the logging properties via an environment file. That does seem to work, so if Firebase Test Lab Robo provides the adb logcat output from apps that run remotely, then adding an environment file to the APK might be a strategy for this issue too:

  1. Add a text file such as environment.txt to the Xamarin.Android app project.

  2. Set the contents to:

    debug.mono.log=default,assembly
    MONO_LOG_LEVEL=debug
    MONO_LOG_MASK=dll
    
  3. Set the Build Action of the file to AndroidEnvironment in the Properties pane.

  4. Clean the solution and build the new APK.

@todorspetkov
Copy link
Author

By chance I was working today on a different issue that required additional logging, and for that issue I checked if it was possible to set the logging properties via an environment file. That does seem to work, so if Firebase Test Lab Robo provides the adb logcat output from apps that run remotely, then adding an environment file to the APK might be a strategy for this issue too:

  1. Add a text file such as environment.txt to the Xamarin.Android app project.
  2. Set the contents to:
    debug.mono.log=default,assembly
    MONO_LOG_LEVEL=debug
    MONO_LOG_MASK=dll
    
  3. Set the Build Action of the file to AndroidEnvironment in the Properties pane.
  4. Clean the solution and build the new APK.

I performed these operations and am including the logcat output (quite long) in attachment.

web-build_2020-06-10T08-20-36.809Z_iim9-hwALE-H-21-en_US-portrait-logcat.txt

@grendello
Copy link
Contributor

So, the problem is shown here:

06-10 01:27:01.911: I/monodroid-assembly(21708): Trying to load shared library '/data/app/it.giunko.junker-1/lib/arm64/./libmono-native.so'
06-10 01:27:01.921: I/monodroid-assembly(21708): Failed to load shared library '/data/app/it.giunko.junker-1/lib/arm64/./libmono-native.so'. dlopen failed: could not load library "libmonosgen-2.0.so" needed by "/data/app/it.giunko.junker-1/lib/arm64/./libmono-native.so"; caused by library "libmonosgen-2.0.so" not found
06-10 01:27:01.921: I/monodroid-assembly(21708): Trying to load shared library '/data/app/it.giunko.junker-1/lib/arm64/./libmono-native.so'
06-10 01:27:01.921: I/monodroid-assembly(21708): Failed to load shared library '/data/app/it.giunko.junker-1/lib/arm64/./libmono-native.so'. dlopen failed: could not load library "libmonosgen-2.0.so" needed by "/data/app/it.giunko.junker-1/lib/arm64/./libmono-native.so"; caused by library "libmonosgen-2.0.so" not found
06-10 01:27:01.921: I/monodroid-assembly(21708): Trying to load shared library '/data/app/it.giunko.junker-1/lib/arm64/./libmono-native.so'
06-10 01:27:01.921: I/monodroid-assembly(21708): Failed to load shared library '/data/app/it.giunko.junker-1/lib/arm64/./libmono-native.so'. dlopen failed: could not load library "libmonosgen-2.0.so" needed by "/data/app/it.giunko.junker-1/lib/arm64/./libmono-native.so"; caused by library "libmonosgen-2.0.so" not found

Only this is not true... libmonosgen-2.0.so (the Mono runtime) is available and loaded, or otherwise the app wouldn't start at all (Xamarin.Android runtime depends on the same shared library) and also from the logs we see that the app is running its managed code, which means the Mono runtime was loaded, initialized and is
working properly. My guess is that Huawei broke the bionic (Android libc) by (possibly?) reintroducing this issue which was fixed in API level 18 where Android wasn't able to follow shared library dependencies to load other required shared libraries (in this case libmono-native.so depends on libmonosgen-2.0.so). The dynamic linker should see that libmonosgen-2.0.so is already mapped into the process memory and resolve the dependency correctly, and that's how it works on other devices. At this point it's hard to say what the fix is because we still have only a vague idea on what's the underlying cause of the Huawei device behavior.

@todorspetkov
Copy link
Author

I do not know how or why but we started using Android Material Design and switched the following components from:
Theme.AppCompat
android.support.design.widget.TabLayout
android.support.v7.widget.Toolbar
to :
Theme.MaterialComponents
com.google.android.material.bottomnavigation.BottomNavigationView
com.google.android.material.appbar.MaterialToolbar

After these changes the app started working on all Robo Test devices from Android 21 to Android 29...

We will be publishing a new release shortly and I will be monitoring Firebase Crashlytics to see whether the problem has really disappeared...

@todorspetkov
Copy link
Author

Unfortunately I am still receiving this crash data for some Android SDK 21/22 devices...
Any idea what the cause/solution might be?

@grendello
Copy link
Contributor

It's really hard to determine the cause without being able to access the device and the information we currently have appears to point to some problem with Huawei devices. However, I've just seen this issue which appears to be the same problem, but reproducible on an emulator. I'll try to reproduce it locally and will update the issues once I know anything more. In the meantime, @todorspetkov, could you check if you can reproduce the issue in an x86-64 Android 5.0/5.1 emulator?

@todorspetkov
Copy link
Author

todorspetkov commented Jun 23, 2020

@grendello I setup two Virtual Devices using Android Studio, one using Android 5.0 (Google APIs) and one using Android 5.1 (Google APIs): on both I was able to reproduce the same crash using a release build of our app.

@todorspetkov
Copy link
Author

todorspetkov commented Jun 23, 2020

Update: I split our release build and produced an x86 only apk and a x86_64 only apk. On both virtual devices the x86 only apk runs fine but the x86_64 only apk crashes with above stacktrace...

Just as quick fix: could I exclude x86_64 ABI from release builds and include x86 only? This should run on x86_64 CPU cell phones, right?! Or does Google Play Store require the x86_64 mandatorily?

@grendello
Copy link
Contributor

@todorspetkov yes, x86 should run just fine on x86_64 and in real world the latter are few and far between, so you should be fine. Regarding the fix, please see the issue I linked to - I hope to have a PR up soon which will probably fix your problem as well.

@todorspetkov
Copy link
Author

Ok, after going through the Google Play Console docs it seems that since Agust 1 2019, x86 cannot be included alone - one must also include x86_64 when publishing apps in the store (
https://developer.android.com/distribute/best-practices/develop/64-bit )...

So we will have to wait for the bug-fix...

grendello added a commit to grendello/xamarin-android that referenced this issue Jun 23, 2020
Fixes: dotnet#4772
Fixes: dotnet#4852

Fixes apply to the the **Release** builds on Android 5.x devices.

Android 5.x devices have a bug in their 64-bit dynamic linker which
prevents it from correctly resolving shared library dependencies when a
library required by the one currently being loaded is not found in the
same directory.  The problem is that the Android dynamic linker on those
devices fails to properly interpret the internal library name (so-called
`SONAME`, contained in the `DT_SONAME` field in the ELF executable
header) when checking whether the library is already loaded in the
process memory.  Failing that check, the loader proceeds to look for the
library **file** on the disk/storage medium in the predefined paths.
Since `libmonosgen-2.0.so` and other libraries are not found in those
paths, the search fails and the linker returns an error.  Later versions
of Android fix the bug in that the `DT_SONAME` field is used to properly
look up already loaded shared libraries and thus the dependency
resolution succeeds.

The solution here is to use the Java API, `System.loadLibrary`, to
preload `libmono-native.so` because the Java API is able to somehow
figure out that the dependent libraries are found in the same directory
and load them to satisfy the requirements.  We could probably implement
the same algorithms in our native code, but it feels it would be a
wasted effort since Android versions above 5.x work correctly.
@grendello
Copy link
Contributor

@todorspetkov The above PR should fix your issue as well - on devices, in Release build. The Debug build with shared runtime will not be fixed - please refer to this comment for explanation why :)

@todorspetkov
Copy link
Author

Hi @grendello when do you expect this bugfix to make it into a xamarin-android official update? Really appreciate your help, thanks a lot.

grendello added a commit to grendello/xamarin-android that referenced this issue Jun 24, 2020
Fixes: dotnet#4772
Fixes: dotnet#4852

Fixes apply to the the **Release** builds on Android 5.x devices.

Android 5.x devices have a bug in their 64-bit dynamic linker which
prevents it from correctly resolving shared library dependencies when a
library required by the one currently being loaded is not found in the
same directory.  The problem is that the Android dynamic linker on those
devices fails to properly interpret the internal library name (so-called
`SONAME`, contained in the `DT_SONAME` field in the ELF executable
header) when checking whether the library is already loaded in the
process memory.  Failing that check, the loader proceeds to look for the
library **file** on the disk/storage medium in the predefined paths.
Since `libmonosgen-2.0.so` and other libraries are not found in those
paths, the search fails and the linker returns an error.  Later versions
of Android fix the bug in that the `DT_SONAME` field is used to properly
look up already loaded shared libraries and thus the dependency
resolution succeeds.

The solution here is to use the Java API, `System.loadLibrary`, to
preload `libmono-native.so` because the Java API is able to somehow
figure out that the dependent libraries are found in the same directory
and load them to satisfy the requirements.  We could probably implement
the same algorithms in our native code, but it feels it would be a
wasted effort since Android versions above 5.x work correctly.
@grendello
Copy link
Contributor

@todorspetkov we first need to see the PR merged, I don't think we're going to see the fix in the upcoming 16.7 release, though. However, I can give you our Java startup code rebuilt with the fix so that you can replace it in your installation and rebuild your app with the fix. Please let me know if you'd like to do that, if only to test the fix.

@todorspetkov
Copy link
Author

@grendello Yes I would like to try out the fix. I will probabely need instructions on what to do exactly :-).

@grendello
Copy link
Contributor

xa-java-runtime.zip

@todorspetkov no worries, it's not that hard :). Download the attachment here, unpack it in some location. Then locate your Xamarin.Android installation tree, it should be in C:\\Program Files (x86)\Microsoft Visual Studio\2019\[EDITION]\MSBuild\Xamarin\Android - at this location you will find 4 files corresponding to the files in the above zip, make backup copies of the originals and replace them with those from the attached zip archive. Then rebuild your application from scratch (remove all bin and obj) and test.

@todorspetkov
Copy link
Author

@grendello Ok I performed the steps you described and produced an apk that now runs on the Emulators without problems. Now I am running a battery of tests using Firebase Robo. Just a quick question: this fix is for Android 5.x devices based both on x86 and Arm platforms, right?

@grendello
Copy link
Contributor

@todorspetkov great that it works for you! Yes, it's for all the supported architectures

jonpryor pushed a commit that referenced this issue Jun 24, 2020
Fixes: #4772
Fixes: #4852

Context: https://issuetracker.google.com/issues/36950617

Fixes apply to the the **Release** builds on Android 5.x devices.

A Xamarin.Android application contains multiple native libraries:

	$ adb shell pm list packages -f | grep -i hello
	package:/data/app/com.xamarin.android.helloworld-_-zYezFQQsuaiegto4HlCw==/base.apk=com.xamarin.android.helloworld

	$ adb shell ls /data/app/com.xamarin.android.helloworld-_-zYezFQQsuaiegto4HlCw==/lib/arm64
	…
	libmono-native.so
	libmonosgen-2.0.so
	…

Native libraries may have dependencies, e.g. `libmono-native.so`
depends on `libmonosgen-2.0.so` in order to load.

Once Upon A Time, Android's native linker was "not helpful" when
loading native libraries through **dlopen**(3): it wouldn't use the
library's directory to resolve dependencies, and thus
`dlopen("libmono-native.so")` would fail.

[This limitation was (mostly) fixed in Android 4.3 (API-18)][0], but
a variation of this limitation is also present on some Android 5.x
devices (API-21, API-22) when running *64-bit apps*.  For example, if
a C# API call requires loading `libmono-native.so`, then on these
devices the load will fail, as `libmonosgen-2.0.so` can't be found --
which is rather unexpected, as `libmonosgen-2.0.so` is *already*
loaded (!) -- which results in an app crash:

	UNHANDLED EXCEPTION:
	System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
		System.TypeInitializationException: The type initializer for 'PanCardView.Droid.CardsViewRenderer' threw an exception. --->
		System.TypeInitializationException: The type initializer for 'System.Random' threw an exception. --->
		System.DllNotFoundException: libmono-native.so assembly:<unknown assembly> type:<unknown type> member:(null)
	  at (wrapper managed-to-native) Interop+Sys.GetNonCryptographicallySecureRandomBytes(byte*,int)
	  at Interop.GetRandomBytes (System.Byte* buffer, System.Int32 length) <0x7f86c3bbf0 + 0x0001b> in <39e41a681ea94f00bcc87fb130853dc2>:0 
	  at System.Random.GenerateGlobalSeed () <0x7f86cb33f0 + 0x00017> in <39e41a681ea94f00bcc87fb130853dc2>:0 
	  at System.Random..cctor () <0x7f86cb3690 + 0x0000b> in <39e41a681ea94f00bcc87fb130853dc2>:0 
	  …

The problem is that the Android dynamic linker on these devices fails
to properly interpret the internal library name (so-called `SONAME`,
contained in the `DT_SONAME` field in the ELF executable header) when
checking whether the library is already loaded in the process memory.
Failing that check, the loader proceeds to look for the library
**file** on the disk/storage medium in the predefined paths.  Since
`libmonosgen-2.0.so` and other libraries are not found in those paths,
the search fails and the linker returns an error.

Later versions of Android fix the bug in that the `DT_SONAME` field
is used to properly look up already loaded shared libraries and thus
the dependency resolution succeeds.

The solution here is to use the `System.loadLibrary()` Java API to
preload `libmono-native.so`, as the Java API is able to figure out
that the dependent libraries are found in the same directory and load
them to satisfy the requirements.

[0]: https://issuetracker.google.com/issues/36950617
jonpryor pushed a commit that referenced this issue Jun 24, 2020
Fixes: #4772
Fixes: #4852

Context: https://issuetracker.google.com/issues/36950617

Fixes apply to the the **Release** builds on Android 5.x devices.

A Xamarin.Android application contains multiple native libraries:

	$ adb shell pm list packages -f | grep -i hello
	package:/data/app/com.xamarin.android.helloworld-_-zYezFQQsuaiegto4HlCw==/base.apk=com.xamarin.android.helloworld

	$ adb shell ls /data/app/com.xamarin.android.helloworld-_-zYezFQQsuaiegto4HlCw==/lib/arm64
	…
	libmono-native.so
	libmonosgen-2.0.so
	…

Native libraries may have dependencies, e.g. `libmono-native.so`
depends on `libmonosgen-2.0.so` in order to load.

Once Upon A Time, Android's native linker was "not helpful" when
loading native libraries through **dlopen**(3): it wouldn't use the
library's directory to resolve dependencies, and thus
`dlopen("libmono-native.so")` would fail.

[This limitation was (mostly) fixed in Android 4.3 (API-18)][0], but
a variation of this limitation is also present on some Android 5.x
devices (API-21, API-22) when running *64-bit apps*.  For example, if
a C# API call requires loading `libmono-native.so`, then on these
devices the load will fail, as `libmonosgen-2.0.so` can't be found --
which is rather unexpected, as `libmonosgen-2.0.so` is *already*
loaded (!) -- which results in an app crash:

	UNHANDLED EXCEPTION:
	System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
		System.TypeInitializationException: The type initializer for 'PanCardView.Droid.CardsViewRenderer' threw an exception. --->
		System.TypeInitializationException: The type initializer for 'System.Random' threw an exception. --->
		System.DllNotFoundException: libmono-native.so assembly:<unknown assembly> type:<unknown type> member:(null)
	  at (wrapper managed-to-native) Interop+Sys.GetNonCryptographicallySecureRandomBytes(byte*,int)
	  at Interop.GetRandomBytes (System.Byte* buffer, System.Int32 length) <0x7f86c3bbf0 + 0x0001b> in <39e41a681ea94f00bcc87fb130853dc2>:0 
	  at System.Random.GenerateGlobalSeed () <0x7f86cb33f0 + 0x00017> in <39e41a681ea94f00bcc87fb130853dc2>:0 
	  at System.Random..cctor () <0x7f86cb3690 + 0x0000b> in <39e41a681ea94f00bcc87fb130853dc2>:0 
	  …

The problem is that the Android dynamic linker on these devices fails
to properly interpret the internal library name (so-called `SONAME`,
contained in the `DT_SONAME` field in the ELF executable header) when
checking whether the library is already loaded in the process memory.
Failing that check, the loader proceeds to look for the library
**file** on the disk/storage medium in the predefined paths.  Since
`libmonosgen-2.0.so` and other libraries are not found in those paths,
the search fails and the linker returns an error.

Later versions of Android fix the bug in that the `DT_SONAME` field
is used to properly look up already loaded shared libraries and thus
the dependency resolution succeeds.

The solution here is to use the `System.loadLibrary()` Java API to
preload `libmono-native.so`, as the Java API is able to figure out
that the dependent libraries are found in the same directory and load
them to satisfy the requirements.

[0]: https://issuetracker.google.com/issues/36950617
@grendello grendello removed the need-info Issues that need more information from the author. label Jul 10, 2020
@brendanzagaeski
Copy link
Contributor

brendanzagaeski commented Jul 14, 2020

Release status update

A new Preview version of Xamarin.Android has now been published that includes the fix for this item (for apps built in the Release configuration). The fix is not yet included in a Release version of Xamarin.Android. I will update this again when a Release version is available that includes the fix.

Fix included in Xamarin.Android 11.0.0.3.

Fix included on Windows in Visual Studio 2019 version 16.7 Preview 4. To try the Preview version that includes the fix, check for the latest updates in Visual Studio Preview.

Fix included on macOS in Visual Studio 2019 for Mac version 8.7 Preview 4. To try the Preview version that includes the fix, check for the latest updates on the Preview updater channel.

@brendanzagaeski
Copy link
Contributor

Release status update

A new Release version of Xamarin.Android has now been published that includes the fix for this item (for apps built in the Release configuration).

Fix included in Xamarin.Android SDK version 11.0.0.3.

Fix included on Windows in Visual Studio 2019 version 16.7. To get the new version that includes the fix, check for the latest updates or install the most recent release from https://visualstudio.microsoft.com/downloads/.

Fix included on macOS in Visual Studio 2019 for Mac version 8.7. To get the new version that includes the fix, check for the latest updates on the Stable updater channel.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants