* Fix monodroid COMMON_CFLAGS usage and always build with RELEASE.
The primary problem was that when app launches it tries to load assemblies:
W/monodroid( 2061): Using override path: /data/data/com.xamarin.android.helloworld/files/.__override__
It should not happen, because we don't have fastdev here.
However, it was weird, that the problem occured even with app Release builds.
Turned out that in src/monodroid, Android.mk referenced COMMON_FLAGS,
which did not exist. Fix typo.
Then, since we don't have fastdev, monodroid needs to be built always
in RELEASE mode. So, add -DRELEASE=1 even for Debug build.
* Remove RELEASE build flag from common. Instead default xabuild to Release.
Allow the Java.Interop checkout directory to be specified by
overriding the `$(JavaInteropSourceDirectory)` MSBuild property.
Project files should use the `$(JavaInteropFullPath)` MSBuild
property, which is computed as `Path.GetFullPath()` for the
`$(JavaInteropSourceDirectory)` value.
Normally `$(JavaInteropSourceDirectory)` wouldn't need to be
overridden; the current use case is to allow a CI-like environment
which grabs the latest commit of every referenced module to make sure
they all work together. (Note: such a "CI-like environment"
DOES NOT (yet) EXIST. This commit is to help *permit* such a thing.)
@atsushieno and I are trying to figure out why `src/Mono.Posix` builds
for me on OS X but fails for him in a (relatively) clean Linux
environment:
CSC: error CS0518: The predefined type `System.Object' is not defined or imported
`System.Object` couldn't be found because `System.Runtime.dll` wasn't
being provided to the compiler.
Further investigation shows that the reason it built on OS X was
because OS X had a pre-existing system Xamarin.Android install, which
was being used to resolve framework directories:
# Works on OS X:
# Note: Mono.framework/External/xbuild-frameworks/MonoAndroid is a symlink
# into Xamarin.Android.framework, i.e. the system Xamarin.Android install
Task "GetReferenceAssemblyPaths"
Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Looking for framework 'MonoAndroid,Version=v1.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks'
Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0'
Done executing task "GetReferenceAssemblyPaths"
# Fails on Linux:
Target _GetReferenceAssemblyPaths:
warning : Unable to find framework corresponding to the target framework moniker 'MonoAndroid,Version=v1.0'. Framework assembly references will be resolved from the GAC, which might not be the intended behavior.
Turns Out™, the error can be reproduced on OS X by "removing" the
system Xamarin.Android install:
$ cd /Library/Frameworks/Mono.framework/External/xbuild-frameworks
$ sudo mv MonoAndroid _MonoAndroid
Task "GetReferenceAssemblyPaths"
Using task GetReferenceAssemblyPaths from Microsoft.Build.Tasks.GetReferenceAssemblyPaths, Microsoft.Build.Tasks.v4.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Looking for framework 'MonoAndroid,Version=v6.0' in root path '/Library/Frameworks/Mono.framework/External/xbuild-frameworks'
Unable to find framework definition file '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v6.0/RedistList/FrameworkList.xml' for Target Framework Moniker 'MonoAndroid,Version=v6.0'
Looking for framework 'MonoAndroid,Version=v6.0' in root path '/Library/Frameworks/Mono.framework/Versions/4.4.0/lib/mono/4.5/../xbuild-frameworks'
Unable to find framework definition file '/Library/Frameworks/Mono.framework/Versions/4.4.0/lib/mono/4.5/../xbuild-frameworks/MonoAndroid/v6.0/RedistList/FrameworkList.xml' for Target Framework Moniker 'MonoAndroid,Version=v6.0'
.../Microsoft.Common.targets: warning : Unable to find framework corresponding to the target framework moniker 'MonoAndroid,Version=v6.0'. Framework assembly references will be resolved from the GAC, which might not be the intended behavior.
Done executing task "GetReferenceAssemblyPaths"
(Not sure why it's looking for *v6.0*`, but it can't find the
framework at all, so that's consistent with Linux.)
The fix is to set the `$(TargetFrameworkRootPath)` MSBuild property,
which is provided to the [`GetReferenceAssemblyPaths.RootPath`][0]
property, and allows controlling which locations are searched for
frameworks.
Unfortunately, `$(TargetFrameworkRootPath)` needs to be set to
`bin\$(Configuration)\lib\xbuild-frameworks`, which means
`$(Configuration)` needs to be set *before*
`$(TargetFrameworkRootPath)` is set. Furthermore, since we want to set
`$(TargetFrameworkRootPath)` in `Configuration.props`, this means that
we need to audit all locations which import `Configuration.props` to
ensure that `$(Configuration)` is set before the import.
Add `$(TargetFrameworkRootPath)` to `Configuration.props`, and audit
all uses of `Configuration.props` to ensure `$(Configuration) is set.
[0]: https://msdn.microsoft.com/en-us/library/microsoft.build.tasks.getreferenceassemblypaths.rootpath.aspx
Fix monodroid SDK detection that depended on non-existent file.
We don't build DebugRuntime apk in this new source set anymore, so
do not look for the file in our SDK sanity checker.
Additional warning logs are added because, we should do that.
(Otherwise we will keep ignorant of the actual cause of the
problem forever.)
Change $(OutputPath) for api-xml-adjuster.csproj to be
bin/$(Configuration)/lib/mandroid instead of bin/$(Configuration).
This is more in keeping with the Xamarin.Android install structure.
(IDEs?! We don't need no stinkin' IDEs! [0, 1])
`tools/scripts/xabuild` is an `xbuild` ("MSBuild") -using script to
support building Xamarin.Android projects from the command-line,
without modifying or replacing the "system" Xamarin.Android install.
Also handy if there are multiple development branches available.
`tools/scripts/xabuild` takes the same command-line arguments as
xbuild(1) and MSBuild, allowing projects to be built and application
packages to be created:
${xamarin-android-checkout-path}/tools/scripts/xabuild /t:SignAndroidPackage
adb install bin/Debug/*-Signed.apk
Xamarin.Android.Build.Tasks.dll is updated to look for an alternate,
*available*, path to `libmonosgen-2.0.so`, and to remove the
%(Reference.Private) metadata so that all required assemblies are
installed into $(OutputPath). (Previous versions of Xamarin.Android
would encode the ABI into the filename, but this encoding should no
longer be necessary.)
android-toolchain is altered to provide `_GetAndroidNdkDirectory` and
`_GetAndroidNdkDirectory` targets, so that the xabuild script can
properly determine the path to the $(AndroidToolchainDirectory)
location.
[0]: In the spirit of: https://www.youtube.com/watch?v=VqomZQMZQCQ
[1]: Seriously, we often like to keep the "system" Xamarin.Android
untouched and unchanged, so that we can more easily build filed
bugs/etc., so the easiest way to build a Xamarin.Android project
from a development branch is from an `xbuild` wrapper script and
building from the command line [2].
[2]: https://developer.xamarin.com/guides/android/under_the_hood/build_process/#Build_Targets