Bug 30106 - "Use Compile using SDK version" Results in an Incorrect minSdkVersion in AndroidManifest.xml
Summary: "Use Compile using SDK version" Results in an Incorrect minSdkVersion in Andr...
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: 7.0 (C8)
Assignee: Jonathan Pryor
Depends on:
Reported: 2015-05-14 20:15 UTC by Jimmy [MSFT]
Modified: 2016-05-18 20:04 UTC (History)
8 users (show)

Tags: _XVSC6SR2
Is this bug a regression?: ---
Last known good build:

Manifests and build outputs (7.99 KB, application/zip)
2015-05-14 20:15 UTC, Jimmy [MSFT]

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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.

Related Links:

Description Jimmy [MSFT] 2015-05-14 20:15:16 UTC
Created attachment 11209 [details]
Manifests and build outputs

*** Overview ***
Setting the Minimum Android to Target option to "Use Compile using SDK" does not result in android:minSdkVersion being set to the right API level in the manifest file. Instead it sets android:minSdkVersion="11" regardless of what the actual API level is used to compile. This occurs in both debug and release configurations.

Changing the option to a specific API level behaves correctly and android:minSdkVersion is set to the selected API level.

Regression Status: Xamarin 3.9.547 does _not_ experience this issue.

I've attached two AndroidManifest.xml files showing the difference and the build output for each build.

*** Steps to Reproduce ***
1.  Create a new Android project or open an existing project
2.  Right click the Android project and go to "Properties > Application"
3.  Set Minimum Android to Target to "Use Compile using SDK"
4.  Rebuild the project so it is cleaned and rebuilt
5.  Go to [project location]\obj\Debug\android\
6.  Open "AndroidManifest.xml" and note that android:minSdkVersion="11"
7.  Right click the Android project and go to "Properties > Application"
8.  Set Minimum Android to Target to a specific API level
9.  Rebuild the project
10. Go to [project location]\obj\Debug\android\
11. Open "AndroidManifest.xml" and note that android:minSdkVersion is set to selected API level

*** Actual Results ***
"Use Compile using SDK" ignores the compiling SDK version and defaults to setting android:minSdkVersion="11"

*** Expected Results ***
"Use Compile using SDK" sets android:minSdkVersion to the SDK version used to compile

*** Environment Info ***
Microsoft Visual Studio Professional 2013
Version 12.0.31101.00 Update 4
Microsoft .NET Framework
Version 4.5.51641

Installed Version: Professional

Team Explorer for Visual Studio 2013   06177-004-0444002-02323
Microsoft Team Explorer for Visual Studio 2013

Visual Basic 2013   06177-004-0444002-02323
Microsoft Visual Basic 2013

Visual C# 2013   06177-004-0444002-02323
Microsoft Visual C# 2013

Visual C++ 2013   06177-004-0444002-02323
Microsoft Visual C++ 2013

Visual F# 2013   06177-004-0444002-02323
Microsoft Visual F# 2013

Visual Studio 2013 Code Analysis Spell Checker   06177-004-0444002-02323
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker

Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.

The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.

Windows Phone SDK 8.0 - ENU   06177-004-0444002-02323
Windows Phone SDK 8.0 - ENU

Application Insights Tools for Visual Studio Package   1.0
Application Insights Tools for Visual Studio

Common Azure Tools   1.3
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Microsoft Advertising SDK for Windows Phone   
Microsoft Advertising SDK for Windows Phone

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

Multilingual App Toolkit   3.1.1250.0
Multilingual App Toolkit helps you localize your Windows Store app by providing file management, pseudo and machine translation, translation editor, and build integration. http://go.microsoft.com/fwlink?linkid=245767

NuGet Package Manager   2.8.50926.663
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

PowerShell Tools   1.3
Provides file classification services using PowerShell

PreEmptive Analytics Visualizer   1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.

Windows Phone 8.1 SDK Integration   1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.

Xamarin   3.11.558.0 (0f136e1)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android (cb23915ae0ecb65f7bb956231fae0e234f66223e)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.Forms Intellisense   1.0
Provides intellisense for Xamarin.Forms in the XML editor.

Xamarin.iOS (4ef5acddd229f2115678f0886b173075eeb8350e)
Visual Studio extension to enable development for Xamarin.iOS.

Xamarin.iOS Unified Migration   1.0
Automated migration for Xamarin iOS Classic projects to Unified

Xamarin.TestCloud.Integration   1.0
Early preview of Xamarin Test Cloud integration
Comment 2 Abhishek 2016-05-11 11:53:57 UTC
I have tried this issue and able to reproduce this issue with the following build:

To verify this issue I have checked this issue with latest C7 build:

Observing the same reported behavior at my end. I have followed the steps given in the bug description. After setting Minimum Android to Target to "Use Compile using SDK". It will set the default android:minSdkVersion="11".

Screencast: http://www.screencast.com/t/FoeC9Qs45
Android Manifest: https://gist.github.com/Abhishekk360/98a77c848c7c96b047c1743531a25e5c
Build Output: https://gist.github.com/Abhishekk360/df75e273070884e59919d42bcb8a3816

Hence reopening this issue. Let me know If I can provide any other details.

Comment 3 Abhishek 2016-05-13 12:41:36 UTC
I have checked this issue with latest C7 build on Windows and Mac XS and I am observing that after selecting minimum Android Version: Automatic-Use target framework version (API23) and build the application. Go to [project location]\obj\Debug\android\ and Open "AndroidManifest.xml" and observe android:minSdkVersion="11". 

Windows Environment:

Screencast: http://www.screencast.com/t/rjzsyhzQ
AndroidManifest: https://gist.github.com/Abhishekk360/56b1ca4d369c211910eafa39cde1a99a
Build Output: https://gist.github.com/Abhishekk360/ea1b4b3b9fb9233315c43c435027fd52

Mac Environment

Screencast: http://www.screencast.com/t/4I85vEPm
AndroidManifest: https://gist.github.com/Abhishekk360/f70634c8318e05c95ecec47350972bee
Build Output: https://gist.github.com/Abhishekk360/92dca90f742f4d3296db8f13cf998739

Just let me know if I can provide and other details.

Comment 4 Jonathan Pryor 2016-05-18 20:04:40 UTC
This is By Design and documented:


If Properties\AndroidManifest.xml doesn't specify a //uses-sdk/@android:minSdkVersion value, then the behavior before Xamarin.Android 5.1 was to use the Android SDK version, which was usually the $(TargetFrameworkVersion).

This as changed with Xamarin.Android 5.1 to be "11" when $(TargetFrameworkVersion) was >= API-11, because it was extremely annoying otherwise.

Pre-5.1, if you had an Android API preview SDK installed on the development machine *but not the target device*, building the default project would result in an app which couldn't be deployed to the target device. This was easily fixed by overriding the minSdkVersion value, but the need to almost always do that was annoying.