I started with a fresh clone of xamarin-android
and checked out the d15-7
branch.
Need to specify MSBUILD=msbuild
if we plan on using VS for Mac:
make prepare all MSBUILD=msbuild
Otherwise, it will build with xbuild
and all our IDEs use msbuild
now.
Because why would it be that easy?
If you have difficulty getting external/Java.Interop
's prepare step to work, place the following in external/Java.Interop/bin/BuildDebug/JdkInfo.props
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Choose>
<When Condition=" '$(JdkJvmPath)' == '' ">
<PropertyGroup>
<JdkJvmPath>/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/jre/lib/jli/libjli.dylib</JdkJvmPath>
</PropertyGroup>
<ItemGroup>
<JdkIncludePath Include="/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/include" />
<JdkIncludePath Include="/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/include/darwin" />
</ItemGroup>
</When>
</Choose>
<PropertyGroup>
<JavaCPath Condition=" '$(JavaCPath)' == '' ">/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/bin/javac</JavaCPath>
<JarPath Condition=" '$(JarPath)' == '' ">/Library/Java/JavaVirtualMachines/jdk1.8.0_152.jdk/Contents/Home/bin/jar</JarPath>
</PropertyGroup>
</Project>
Make sure to change these paths as needed for your system.
Make sure you also see something like this:
_DownloadBundle:
Downloading `https://xamjenkinsartifact.azureedge.net/xamarin-android/...
Xamarin.Android's CI system caches builds of mono
and a few other native libraries. They are quite time consuming to build.
If it lists a 404 error, than means the build is about to attempt to build mono
.
You don't want to mess with this, so check and see if a recent commit is bumping mono and/or modifying mono-runtimes.csproj
.
You may prefer to back up a commit or two:
#NOTE: this will clear changes in your working copy, too!
git reset --hard HEAD~1
Change the number 1
to specify how many commits you want to back up to. git pull
will move back forward to the latest if you mess up.
You might also see:
build-tools/scripts/RequiredPrograms.targets(35,5): warning : Please download `https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2017-12/41/MonoFramework-MDK-5.10.0.47.macos10.xamarin.universal.pkg` into `~/android-archives/MonoFramework-MDK-5.10.0.47.macos10.xamarin.universal.pkg`.
build-tools/scripts/RequiredPrograms.targets(40,5): error : Could not find required program 'mono'. Please run: installer -pkg "~/android-archives/MonoFramework-MDK-5.10.0.47.macos10.xamarin.universal.pkg" -target /
You can fix this by running:
wget https://xamjenkinsartifact.azureedge.net/build-package-osx-mono/2017-12/41/MonoFramework-MDK-5.10.0.47.macos10.xamarin.universal.pkg -P ~/android-archives/
sudo installer -pkg ~/android-archives/MonoFramework-MDK-5.10.0.47.macos10.xamarin.universal.pkg -target /
Make sure the URL and paths match the error message, and retry the build.
I opened VS Code, and opened src/Mono.Android/Android.App/Activity.cs
.
I added some nonsense method:
public int Add (int x, int y)
{
return x + y;
}
Then built again, making sure to use MSBUILD=msbuild
:
make MSBUILD=msbuild
Not passing make
a target implies make all
.
I opened VS for Mac and created a blank Xamarin.Android app (latest and greatest).
I opened the csproj
and modified the reference to Mono.Android.dll
(Right Click | Tools | Edit File):
<Reference Include="Mono.Android">
<HintPath>/Users/youruser/Desktop/Git/xamarin-android/bin/Debug/lib/xamarin.android/xbuild-frameworks/MonoAndroid/v8.1/Mono.Android.dll</HintPath>
</Reference>
I also made sure TargetFrameworkVersion
is set to v8.1
in the csproj
.
After modifying the csproj
, I had to restart VS for Mac.
I opened MainActivity.cs
in my project and added this line:
int result = Add(1, 2);
I added a breakpoint and ran the project.
MissingMethodException
, now that's embarrassing.