Bug 31807 - [XA 5.1.4] "cannot find libmonosgen-2.0.so in override_dir" when "Use Shared Runtime" is enabled
Summary: [XA 5.1.4] "cannot find libmonosgen-2.0.so in override_dir" when "Use Shared ...
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 5.1
Hardware: PC Mac OS
: Normal normal
Target Milestone: master
Assignee: dean.ellis
Depends on:
Reported: 2015-07-09 18:16 UTC by Brendan Zagaeski (Xamarin Support)
Modified: 2017-03-21 20:21 UTC (History)
9 users (show)

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


Description Brendan Zagaeski (Xamarin Support) 2015-07-09 18:16:23 UTC
I am copying the available information so far into a bug report for tracking.

From: http://forums.xamarin.com/discussion/comment/138233/#Comment_138233:

> My app is crashing on a Galaxy Nexus (Android 4.3) when built for debug with
> the "Use Shared Runtime" option. Works without that option.
> Compile using Android version is "Use Latest Platform (API Level 21), min
> Android to target is "API Level 15", target Android version is "Use Compile
> using SDK version".
> 07-09 11:32:30.400 W/monodroid( 9918): Using override path: /data/data/au.com.obansolutions.mobile/files/.__override__
> 07-09 11:32:30.400 W/monodroid( 9918): Using override path: /storage/emulated/0/Android/data/au.com.obansolutions.mobile/files/.__override__
> 07-09 11:32:30.400 W/monodroid( 9918): Trying to load sgen from: /data/data/au.com.obansolutions.mobile/files/.__override__/libmonosgen-2.0.so
> 07-09 11:32:30.400 W/monodroid( 9918): Trying to load sgen from: /storage/emulated/0/Android/data/au.com.obansolutions.mobile/files/.__override__/libmonosgen-2.0.so
> 07-09 11:32:30.400 W/monodroid( 9918): Trying to load sgen from: /data/app-lib/au.com.obansolutions.mobile-1/libmonosgen-2.0.so
> 07-09 11:32:30.400 W/monodroid( 9918): Trying to load sgen from: /data/app-lib/au.com.obansolutions.mobile-1/libmonosgen-32bit-2.0.so
> 07-09 11:32:30.400 W/monodroid( 9918): Trying to load sgen from: /system/lib/libmonosgen-2.0.so
> 07-09 11:32:30.400 F/monodroid( 9918): cannot find libmonosgen-2.0.so in override_dir: /data/data/au.com.obansolutions.mobile/files/.__override__, app_libdir: /data/app-lib/au.com.obansolutions.mobile-1 nor in runtime_libdir as: /system/lib/libmonosgen-2.0.so
> 07-09 11:32:30.400 F/monodroid( 9918): Do you have a shared runtime build of your app with AndroidManifest.xml android:minSdkVersion < 10 while running on a 64-bit Android 5.0 target? This combination is not supported.
> 07-09 11:32:30.400 F/monodroid( 9918): Please either set android:minSdkVersion >= 10 or use a build without the shared runtime (like default Release configuration).
> 07-09 11:32:30.416 I/ActivityManager(  377): Process au.com.obansolutions.mobile (pid 9918) has died.

## Possible regression status: regression between Cycle 5 SR 1 and Cycle 5 SR 2
Comment 2 Brendan Zagaeski (Xamarin Support) 2015-07-09 19:02:20 UTC
There is a chance this issue _might_ be resolved by some fixes that have been made for other Xamarin.Android bugs (for example Bug 31527 (where the Linker setting was involved) and non-public Bug 31575).

Until preliminary builds that include those fixes are available, if any users who are hitting this bug have a chance to add more information, that would be perfect.

## Additional information that would be helpful to add to this bug report for
anyone who can reproduce this issue

(See also

A. Can you reproduce the problem using a "new from template" Android app or Xamarin.Forms app? If not, then if anyone already has (or would be able to quickly create) a minimal test case that demonstrates the problem, please do attach it on this bug report. (See also the KB article link above for some tips about minimizing a test case.)

B. Have any users seen this error on any devices other than Galaxy Nexus, Android 4.3?

C. Does this problem only affect Visual Studio or Xamarin Studio? For example, if any users are hitting this issue in Visual Studio, are you also able to reproduce the problem using Xamarin Studio on Windows?

D. If you manually uninstall both the app and the shared runtime ("Mono Android... Support" and "Mono Shared Runtime") from the device (for example by using the device settings menu), and then re-install the app from the command line using `msbuild` (or `xbuild` on Mac), are the results different?

> msbuild /t:Install AndroidApp1.csproj

E. For thoroughness, you can also copy and paste your detailed version information [1] from either Visual Studio or Xamarin Studio directly in a comment or in a text file attachment.

> [1] https://kb.xamarin.com/customer/portal/articles/1675684-where-can-i-find-my-version-information-and-logs-
Comment 3 Brendan Zagaeski (Xamarin Support) 2015-07-09 19:34:16 UTC
For comparison, when running a "new from template" Android app successfully on an LG Optimus L9, Android 4.1.2 device, the adb logcat log file shows one additional location that is searched for the `libmonosgen-2.0.so` file:

> Trying to load sgen from: /data/data/AndroidApp1/files/.__override__/links/libmonosgen-2.0.so

It seems Xamarin.Android is for some reason skipping this location in the original user report in comment 0?

There is a bit of a suspicious coincidence that the fix for Bug 29130 was released in C5SR2. As I understand it, that fix _added_ some logic to use the `links` directory, so I'm surprised it would somehow cause the `links` directory to get skipped (assuming this is indeed a regression between Cycle 5 SR1 and Cycle 5 SR2).
Comment 5 Radek Doulik 2015-07-17 06:51:28 UTC
Brendan, do you know if it happens also when you rebuild the app completely (clean and then build and deploy). It either means we are unable to create successfully link to 32bit libmonosgen or that the apk has old libmonodroid.

Peter, do you have Galaxy Nexus with 4.3 around? Could you try to reproduce it?
Comment 6 Peter Collins 2015-07-20 17:25:58 UTC
I upgraded one of our Galaxy Nexus devices to 4.3 and was unable to reproduce this when deploying from VS and XS on Win/Mac.
Comment 7 Simon Taylor 2015-07-21 01:33:06 UTC
Looks like the clean target isn't removing everything. Manually removed the obj and bin folders, the app now works.

 Directory of C:\OBTFS\Mobile2\Mobile\Oban.Mobile\Oban.Mobile.Android\obj\Debug

21/07/2015  03:29 PM    <DIR>          .
21/07/2015  03:29 PM    <DIR>          ..
21/07/2015  03:23 PM           922,332 DesignTimeResolveAssemblyReferences.cache

21/07/2015  03:22 PM            13,334 DesignTimeResolveAssemblyReferencesInput.
21/07/2015  03:22 PM                 0 TemporaryGeneratedFile_036C0B5B-1481-4323
21/07/2015  03:22 PM                 0 TemporaryGeneratedFile_5937a670-0e60-4077
21/07/2015  03:22 PM                 0 TemporaryGeneratedFile_E7A71F73-0F8D-4B9B
21/07/2015  03:21 PM    <DIR>          TempPE
               5 File(s)        935,666 bytes
Comment 8 Jeremy Kolb 2015-07-27 12:15:45 UTC
I'm suddenly getting hit by this.  It's occurring on my Samsung Galaxy Tab (Android 5.0.2) but NOT genymotion on the latest stable.
Comment 9 Radek Doulik 2015-07-30 15:26:32 UTC
Dean, could you please look at the Clean target?
Comment 10 dean.ellis 2015-07-30 15:42:42 UTC

The DesignTimeResolveAssemblyReferences.cache, DesignTimeResolveAssemblyReferencesInput.cache, and the TemporaryGeneratedFile* are actually generated by Visual Studio itself not by our build system. Generally we only automatically delete files we have generated. I'm not sure why VS is leaving those around.
Comment 11 Radek Doulik 2015-08-03 14:28:35 UTC
@Dean, so could we improve our Clean target maybe? Or Input, Outputs dependencies? It looks to me as a msbuild issue, where we are generating apk with an old libmonodroid.so from previous installation?

Simon, jkolb, could you please attach a sample project, so that we can reproduce it locally?
Comment 12 Simon Taylor 2015-08-03 20:28:29 UTC
I can't reproduce it locally myself any more - the initial build needs to be with an older version of Xamarin.
Comment 13 PJ 2015-08-17 15:20:07 UTC
Missed freeze for C5SR4. Discussed with JonP - this won't be addressed before C6SR1.
Comment 15 Jonah 2017-01-19 10:31:10 UTC
This error popped up again. Is there any further info? 

I'm working with the following versions:

Xamarin Studio Enterprise
Version 6.1.4 (build 1)
Installation UUID: db69cadc-fa38-476f-b824-a409bed0d8e3
	Mono 4.6.2 (mono-4.6.0-branch/ac9e222) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 406020016


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

Apple Developer Tools
Xcode 8.2.1 (11766.1)
Build 8C1002

Version: (Visual Studio Enterprise Trial)
Hash: 7beaef4
Branch: cycle8-xi
Build date: 2016-12-20 02:58:14-0500

Version: (Visual Studio Enterprise Trial)

Version: (Visual Studio Enterprise Trial)
Android SDK: /Users/Jonah/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		6.0 (API level 23)
		7.0 (API level 24)

SDK Tools Version: 25.2.5
SDK Platform Tools Version: 25.0.3
SDK Build Tools Version: 25.0.2

Java SDK: /usr
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

Android Designer EPL code available here:

Xamarin Android Player
Not Installed

Xamarin Inspector
Hash: 1f3067d
Branch: master
Build date: 11/15/2016 10:13:59 PM

Build Information
Release ID: 601040001
Git revision: e606823f2dd01b4552216c013b597a73bec2068f
Build date: 2017-01-10 17:28:57-05
Xamarin addins: c92d0626d347aaa02839689eaac2961d24c9f446
Build lane: monodevelop-lion-cycle8

Operating System
Mac OS X 10.12.2
Darwin Jonahs-MBP.rug.adroot 16.3.0 Darwin Kernel Version 16.3.0
    Thu Nov 17 20:23:58 PST 2016
    root:xnu-3789.31.2~1/RELEASE_X86_64 x86_64

Enabled user installed addins
MFractor 2.07.00
Addin Maker 1.3.2
FileNesting 0.1
Redth's Addins 1.0.2
Xamarin Inspector

Note You need to log in before you can comment on or make changes to this bug.