Bug 57827 - Compiled Native Library no longer included in APK for referenced Dynamic Shared Library Project
Summary: Compiled Native Library no longer included in APK for referenced Dynamic Shar...
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: 7.3 (15.2)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
Depends on:
Reported: 2017-06-28 11:39 UTC by Seb
Modified: 2017-07-11 15:21 UTC (History)
4 users (show)

Is this bug a regression?: ---
Last known good build:

NativeDebug APK (crashes) (4.48 MB, application/zip)
2017-07-06 12:00 UTC, Seb
NDK APK (doesn't crash) (4.23 MB, application/zip)
2017-07-06 12:02 UTC, Seb

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 57827 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Seb 2017-06-28 11:39:21 UTC
Developing and building from VS 2015 we have up until now followed the second block of advice given about Dynamic Shared Library projects being included if referenced as projects @


This has worked (for several months) until updating to Xamarin Android

Since updating, there are no build errors however at run-time application is failing to find the native library (logcat reports various attempts to find .so file at different paths but never succeeds).

I built out a full APK to check if .so file was in there, but it appears to be missing.

We have managed to work around the issue by explicitly including/linking the compiled .so file as AndroidNativeLibrary in the Android application's project and following other advice specified in the above link's first set of instructions - but would obviously prefer to not have to do that.

Anyone else getting same issue?
Comment 1 Jon Douglas [MSFT] 2017-07-05 17:10:17 UTC
Hi Seb,

Can you please use an app from the Google Play store like "Native Libs Monitor" to ensure that the .so is making it to the application install? (apk)

To figure out if this is a regression, can you please include the build version information that you know this worked on with the project reference method?

If you can replicate this behavior with the sample like https://developer.xamarin.com/samples/monodroid/SanAngeles_NDK/ please let us know. This way we can figure out what happened and ensure that the .so is making the final APK. Otherwise please upload a sample project that demonstrates the behavior.
Comment 2 Seb 2017-07-06 12:00:14 UTC
Created attachment 23342 [details]
NativeDebug APK (crashes)
Comment 3 Seb 2017-07-06 12:02:09 UTC
Created attachment 23343 [details]
NDK APK (doesn't crash)
Comment 4 Seb 2017-07-06 12:06:30 UTC
I have attached APKs built from the SanAngeles example.

As experienced previously,
The solution where the .so files are included in the Solution (the NDK example) builds correctly and runs as expected.

The solution where the native lib is referenced (NativeDebug example) the application crashes with a DllNotFoundException.

07-06 12:52:22.299: I/MonoDroid(11814): UNHANDLED EXCEPTION:
07-06 12:52:22.359: I/MonoDroid(11814): System.DllNotFoundException: sanangeles
07-06 12:52:22.359: I/MonoDroid(11814):   at (wrapper managed-to-native) SanAngles.DemoRenderer:nativeInit (intptr)
07-06 12:52:22.359: I/MonoDroid(11814):   at SanAngles.DemoRenderer.OnSurfaceCreated (Javax.Microedition.Khronos.Opengles.IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) [0x00000] in <debefbc3f20c479c935e82ec6e24d3e8>:0 
07-06 12:52:22.359: I/MonoDroid(11814):   at Android.Opengl.GLSurfaceView+IRendererInvoker.n_OnSurfaceCreated_Ljavax_microedition_khronos_opengles_GL10_Ljavax_microedition_khronos_egl_EGLConfig_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_gl, System.IntPtr native_config) [0x00017] in <f81c327f52ad42e492552d1582dc705a>:0 
07-06 12:52:22.359: I/MonoDroid(11814):   at (wrapper dynamic-method) System.Object:9c360c38-5625-4a3b-8fa5-0f807d1cc949 (intptr,intptr,intptr,intptr)
07-06 12:52:22.389: W/dalvikvm(11814): threadid=12: thread exiting with uncaught exception (group=0x41966700)
07-06 12:52:22.399: E/AndroidRuntime(11814): FATAL EXCEPTION: GLThread 217
07-06 12:52:22.399: E/AndroidRuntime(11814): android.runtime.JavaProxyThrowable: System.DllNotFoundException: sanangeles
07-06 12:52:22.399: E/AndroidRuntime(11814):   at (wrapper managed-to-native) SanAngles.DemoRenderer:nativeInit (intptr)
07-06 12:52:22.399: E/AndroidRuntime(11814):   at SanAngles.DemoRenderer.OnSurfaceCreated (Javax.Microedition.Khronos.Opengles.IGL10 gl, Javax.Microedition.Khronos.Egl.EGLConfig config) [0x00000] in <debefbc3f20c479c935e82ec6e24d3e8>:0 
07-06 12:52:22.399: E/AndroidRuntime(11814):   at Android.Opengl.GLSurfaceView+IRendererInvoker.n_OnSurfaceCreated_Ljavax_microedition_khronos_opengles_GL10_Ljavax_microedition_khronos_egl_EGLConfig_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_gl, System.IntPtr native_config) [0x00017] in <f81c327f52ad42e492552d1582dc705a>:0 
07-06 12:52:22.399: E/AndroidRuntime(11814):   at (wrapper dynamic-method) System.Object:9c360c38-5625-4a3b-8fa5-0f807d1cc949 (intptr,intptr,intptr,intptr)
07-06 12:52:22.399: E/AndroidRuntime(11814): 	at md58ed1fcf79056393e92ede40137de35ec.DemoRenderer.n_onSurfaceCreated(Native Method)
07-06 12:52:22.399: E/AndroidRuntime(11814): 	at md58ed1fcf79056393e92ede40137de35ec.DemoRenderer.onSurfaceCreated(DemoRenderer.java:48)
07-06 12:52:22.399: E/AndroidRuntime(11814): 	at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1501)
07-06 12:52:22.399: E/AndroidRuntime(11814): 	at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

I'm sorry but at this time I cant be installing older versions of Xamarin to find the one it last worked with.
Comment 5 Jon Douglas [MSFT] 2017-07-06 18:02:18 UTC

Thank you kindly for your reproductions in a timely manner! I was able to successfully CONFIRM this behavior as I believe this might be a regression with regards to the project reference and deploying the .so. It seems that this behavior has changed.

The interesting thing is that this behavior doesn't exist when debugging an application that includes the vcxproj reference:

    <ProjectReference Include="..\SanAngelesLibrary\SanAngelesLibrary.vcxproj">

However switching over to a RELEASE configuration, there seems to be another issue:

2>Task "MergeApkRecipelists" (TaskId:121)
2>  Task Parameter:RecipeFiles=C:\Users\dougl\Downloads\SanAngeles_NDK\SanAngeles_NativeDebug\x86\Release\lib.so.recipe (TaskId:121)
2>C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common\ImportAfter\Microsoft.Cpp.Android.targets(55,9): error : Unable to open file C:\Users\dougl\Downloads\SanAngeles_NDK\SanAngeles_NativeDebug\x86\Release\lib.so.recipe because 2
2>  Output Property: NativeLibraryAbi= (TaskId:121)
2>  Output Property: NativeHasMismatchedConfigurations=False (TaskId:121)
2>  Output Property: NativeHasMismatchedPlatforms=False (TaskId:121)
2>Done executing task "MergeApkRecipelists" -- FAILED. (TaskId:121)
2>Done building target "GetNativeProjectLibraries" in project "SanAngeles.csproj" -- FAILED.: (TargetId:66)

Although there are some steps blocking additional testing, I can confirm the original report and thus marking this issue as CONFIRMED.
Comment 6 Dominic N [MSFT] 2017-07-11 15:21:29 UTC
For bookkeeping purposes, I'll add that Jamie (https://twitter.com/jcmm33/status/884420105827893248) also reports that he's running into this.