Bug 56786 - Command line build does fails "fatal error: mono/metadata/mono-config.h: No such file or directory"
Summary: Command line build does fails "fatal error: mono/metadata/mono-config.h: No s...
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: General (show other bugs)
Version: 7.4 (15.3)
Hardware: PC Windows
: --- blocker
Target Milestone: 15.2.2
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2017-05-24 08:11 UTC by Amenti
Modified: 2017-05-25 19:00 UTC (History)
10 users (show)

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


Attachments

Description Amenti 2017-05-24 08:11:26 UTC
# Steps to reproduce

Build a Xamarin.Forms Android project via 

%msbuildpath% %projectfilepath% /p:Configuration=Release /t:PackageForAndroid /p:AndroidSupportedAbis=armeabi 

Visual Studio 2015 is used here so %msbuildpath% is usually C:\Program Files (x86)\MSBuild\14.0\Bin\msbuild.exe.

# Expected behavior

Build is successfull like in Xamarin.VisualStudio_4.5.0.443 (double checked by reinstalling old version and then reinstalling new version (Xamarin.VisualStudio_4.5.0.475.msi) where it fails).

# Actual behavior

Build fails with error message:

[cc stderr] obj\Release\bundles\armeabi\temp.c:1:39: fatal error: mono/metadata/mono-config.h: No such file or direct
  ory
  [cc stderr]  #include <mono/metadata/mono-config.h>
  [cc stderr]                                        ^
  [cc stderr] compilation terminated.
  [cc stderr]

# Supplemental info (logs, images, videos)


# Test environment (full version information)
			  
Windows 10
Comment 1 Daniel 2017-05-24 11:38:18 UTC
Can confirm that the issue exists. Used the same steps to reproduce as in description
Comment 2 dean.ellis 2017-05-24 11:50:40 UTC
This is related to commit tamarin-android/master/b6d2360

The problem came from the tamarin-android repo switching over to use the system mono mkbundle rather than compiling its own. The problem being that the mono-config.h files are not present. This has now been fixed in the commit above. 

The new system allows us to pass an additional flag to tell mkbundle NOT to use the headers. however this does require a new version of mkbundle (see mono/master/59737b2a).

Currently the only work around is to disable bundling of assemblies into native code.
Comment 3 Amenti 2017-05-24 13:20:19 UTC
Building with deactivating bundling of assemblies into native code works. However the app crashes after a few seconds after showing the splash screen on the device. I don't know if this is connected.
Comment 4 Brendan Zagaeski (Xamarin Support) 2017-05-24 14:32:42 UTC
> the app crashes after a few seconds after showing the splash screen on
> the device

For a quick cross-reference possibility, that top-level symptom sounds like it might be Bug 56787.  You can check if the device log (`adb logcat`) [1] from when the app crashes matches the information on Bug 56787 to see if it's the same scenario you're hitting.

[1] http://developer.xamarin.com/guides/android/deployment%2C_testing%2C_and_metrics/android_debug_log
Comment 5 Brendan Zagaeski (Xamarin Support) 2017-05-24 14:36:08 UTC
## Bookkeeping note

To help tidy up the autocorrect spelling change in Comment 2, tamarin-android/master/b6d2360 refers to:
https://github.com/xamarin/xamarin-android/commit/b6d2360
Comment 6 Amenti 2017-05-24 14:45:21 UTC
Thanks for the info but it seems to be a linking error. Logcat produces:

E/AndroidRuntime( 2899): java.lang.UnsatisfiedLinkError: Couldn't load monodroid from loader dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/myapk.apk"],nativeLibraryDirectories=[/data/app-lib/myapk, /system/lib]]]: findLibrary returned null

It even happens when I set linking to "None".
Comment 7 Brendan Zagaeski (Xamarin Support) 2017-05-24 14:48:06 UTC
> Couldn't load monodroid from loader

As a preliminary troubleshooting and sanity-check for that issue, you can try manually uninstalling the app from the device, fully cleaning the project (perhaps also manually clearing the bin and obj folders to be extra thorough), and then rebuilding and redeploying the app.
Comment 8 Amenti 2017-05-25 07:31:08 UTC
Cleaning the bin/obj did really help, thanks.
Comment 9 Peter Collins 2017-05-25 18:54:27 UTC
As to the original issue reported here:

> [cc stderr] obj\Release\bundles\armeabi\temp.c:1:39: fatal error: mono/metadata/mono-config.h: No such file or direct
The BundleAssemblies project option should no longer result in a build error and again be working as expected in monodroid/d15-2/9dbc4c53.

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