Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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 on
Developer Community or GitHub with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
(Call it the wonderful case of information duplication...)
Tested against the Mono for Android MonoDevelop Add-in 184.108.40.206.
Updating the minimum android version doesn't update the TargetFrameworkVersion. This needs to be done so that the appropriate Mono.Android.dll assembly is referenced at build time.
1. File -> New Solution / Mono for Android Application / Insert name ; OK.
2. At this point, view ProjectDirectory/ProjectName.csproj. It has:
3. In the Solution pane, select the project, then click
Project > ProjectName Options.
4. In the tree view, select Build / Mono for Android Application.
5. Click the Add Android manifest button.
6. Set Minimum Android version to API Level 4 (Android v1.6).
7. Click OK, save everything.
8. View ProjectDirectory/ProjectName.csproj: it now has:
Specifically, <TargetFrameworkVersion/> is unchanged.
9. Build! (I'm using `build` as it's easier to capture output):
Tool /Developer/MonoAndroid/usr/lib/mandroid/../../bin/smcs execution started with arguments: /noconfig /debug:full /debug+ /optimize- /out:obj/Debug/ScratchTargetFrameworkVersion.dll Activity1.cs Resources/Resource.designer.cs Properties/AssemblyInfo.cs /target:library /define:"DEBUG;__ANDROID__;__ANDROID_1__;__ANDROID_2__;__ANDROID_3__;__ANDROID_4__;__ANDROID_5__;__ANDROID_6__;__ANDROID_7__;__ANDROID_8__" /reference:/Developer/MonoAndroid/usr/lib/mono/2.1/System.dll /reference:/Developer/MonoAndroid/usr/lib/mono/2.1/System.Xml.dll /reference:/Developer/MonoAndroid/usr/lib/mandroid/platforms/android-8/Mono.Android.dll /reference:/Developer/MonoAndroid/usr/lib/mono/2.1/System.Core.dll /warn:4
That's the source compilation line (smcs is executed). The important bit is:
In particular, "android-8", which is TargetFrameworkVersion v2.2. We're supposed to be referencing "android-4" (as that's what we set as the minimum android version).
After setting the minimum android version, the <TargetFrameworkVersion/> element needs to be updated as appropriate, so that when the project is built it refers to correct Mono.Android.dll assembly.
This doesn't make sense. The target framework is the API level you're building against, the minimum version is the minimum version that app will run on. You can build against a newer API level version than the minimum OS version, as long as you detect the OS version at runtime, and limit your API use depending on the OS version.
Ok, so this is what those two settings do:
TargetFramework allows you to use a specific version of the managed libraries.
Minimum Android version sets the minimum android that this application can run
on. Any android devices running versions lower than this won't have this
application available to install.
So, you can target a 2.2 framework, but you can say that your app runs on 1.6.
If you use things that aren't supported in 1.6, you need to check at runtime
which version you're running on and switch code paths appropriately.