Bug 25338 - Xamarin.Android F# Application properties overlap, it always show "Minimum Android version not supported by device" error
Summary: Xamarin.Android F# Application properties overlap, it always show "Minimum An...
Status: RESOLVED FIXED
Alias: None
Product: Visual Studio Extensions
Classification: Xamarin
Component: Android ()
Version: unspecified
Hardware: PC Windows
: Normal normal
Target Milestone: 15.2
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-12-12 10:37 UTC by Horácio J. C. Filho
Modified: 2017-05-29 16:45 UTC (History)
8 users (show)

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


Attachments
Incompatible API Level (143.68 KB, image/png)
2014-12-12 10:37 UTC, Horácio J. C. Filho
Details
Reproducing project and log files from build (64.38 KB, application/x-zip-compressed)
2016-04-26 19:56 UTC, Staffan Einarsson
Details


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 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:
Status:
RESOLVED FIXED

Description Horácio J. C. Filho 2014-12-12 10:37:29 UTC
Created attachment 9053 [details]
Incompatible API Level

Hello guys,

I've created a F# Android application using Xamarin for Visual Studio 3.9.142, the project builds normally as expected but when runs it always shows the error: "Minimum Android version not supported by device".

My device is a JellyBean Android (4.1.2 - API 16).
My application properties:
  - Compile using Android API Level 21
  - Minimum Android to target is API Level 15
  - Target Android version is "Use Compile using SDK version".

It works very well in an C# Xamarin.Android application, it builds and runs very nice :D but in a F# Xamarin.Android application not :'(. 

Please see the photo attached, there is some sort of overlap of the application settings during the build process, the minimum Android to target is API Level 15 in project properties but the dialog shows minimum API Level 19.
Using command-line: aapt list -a [name].apk. I can see that Xamarin.Android simple ignored the minSdkVersion that was API Level 15 and setted it to API Level 19 in generated apk. The minimum Android to target always will be the same that "Compile API Level".

Project Properties -> Android Options -> Always show "Null object cannot be converted to a value type". Unlike common.

Android SDK Settings:
SDK Tools 24.0.1
Platform-tools 21
Build-tools 21.1.2

Visual Studio Settings:
Microsoft Visual Studio Ultimate 2015 Preview
Version 14.0.22310.1 DP
Microsoft .NET Framework
Version 4.5.53349

Installed Version: Ultimate

Architecture and Modeling Tools   00269-30000-00001-AA175
Microsoft Architecture and Modeling Tools
    
UML® and Unified Modeling Language™ are trademarks or registered trademarks of the Object Management Group, Inc. in the United States and other countries.

Visual Basic 2015 Preview   00269-30000-00001-AA175
Microsoft Visual Basic 2015 Preview

Visual C# 2015 Preview   00269-30000-00001-AA175
Microsoft Visual C# 2015 Preview

Visual C++ 2015 Preview   00269-30000-00001-AA175
Microsoft Visual C++ 2015 Preview

Visual F# 2015 Preview   00269-30000-00001-AA175
Microsoft Visual F# 2015 Preview

Visual Studio 2015 Preview Code Analysis Spell Checker   00269-30000-00001-AA175
Microsoft® Visual Studio® 2015 Preview 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   00269-30000-00001-AA175
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.

ErrorList   1.0
Information about my package

JetBrains ReSharper Platform 6   Build 6.0.20141204.190160 on 2014-12-04 19:29:31Z
JetBrains ReSharper Platform package for Microsoft Visual Studio. For more information about ReSharper Platform, visit http://www.jetbrains.com/resharper. Copyright © 2014 JetBrains, Inc.

Microsoft Azure Mobile Services Tools   1.3
Microsoft Azure Mobile Services Tools

Microsoft Code Digger   0.9
Microsoft Code Digger

Microsoft.Pex.VisualStudio   1.0
Pex

NuGet Package Manager   3.0.51103.210
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

SQL Server Data Tools   14.0.41025.0
Microsoft SQL Server Data Tools

Xamarin   3.9.142.0 (e7bacad)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android   4.20.0.34 (49a04b966feb40dfdba49d57ba16249b66d606a6)
Visual Studio plugin to enable development for Xamarin.Android.

Xamarin.iOS   8.6.0.0 (22574c9788a6d607f8d119e4d645f5ce5a346553)
Visual Studio extension to enable development for Xamarin.iOS.
Comment 1 Jonathan Pryor 2014-12-18 16:37:01 UTC
Please attach a project and/or the .fsproj file and  diagnostic build output.
Comment 2 Staffan Einarsson 2016-04-26 19:54:37 UTC
This same thing has happened to me just now. Please see the attached zip containing:
* The F# Visual Studio 2015 solution and project, which is the unmodified template that you get by selecting New Project -> Visual F# -> Blank App (Android).
* The diagnostic build output from having a clean project and then selecting Build -> Deploy Solution, with a default AVD emulator image targeted, at API 15.
* The output from running "aapt list -a <APK>" on the signed apk file under bin/Debug. This shows that the apk has minSdkVersion = 0x17 (23) and not 0x0F (15) as expected.
* The version info from Visual Studio About window.

In short, it seems that even though the manifest has <uses-sdk android:minSdkVersion="15" /> set, the resulting apk gets the same minSdkVersion as the "buildUsing" version of the SDK, which is 23.
Comment 3 Staffan Einarsson 2016-04-26 19:56:58 UTC
Created attachment 15850 [details]
Reproducing project and log files from build
Comment 4 Staffan Einarsson 2016-04-26 20:41:06 UTC
In the build output I found the following:

2>Target "_ValidateAndroidPackageProperties" in file "[...]\Xamarin.Android.Common.targets" from project "[...]\AndroidMinSdkVersionBug.fsproj" (target "_UpdateAndroidResgen" depends on it):
2>Task "CreateProperty" skipped, due to false condition; ('$(AndroidManifest)' != '') was evaluated as ('' != '').

It seems that the fsproj file is missing the AndroidManifest property, which in present in the C# version of the same template project. The problem seems to be solved if I manually add

<AndroidManifest>Properties\AndroidManifest.xml</AndroidManifest>

to the end of the first PropertyGroup in the fsproj file.

So it seems this is more of a bug in the project template than in the build scripts.
Comment 5 Staffan Einarsson 2016-04-26 21:19:46 UTC
The following templates are affected:
* Blank App (Android)
* OpenGL App (Android)

These are not affected:
* Unit Test App (Android)
* Class Library (Android)  (since it does not have a manifest file)
Comment 6 Jose Gallardo 2016-12-22 21:28:31 UTC
Switching back to NEW as the info was provided.
Changing the Target Milestone for visibility.
Thanks.
Comment 7 Juan Marcelo Tondato 2017-05-29 16:45:43 UTC
Hi,
As we've introduced several improvements around this area, I'll mark the bug as resolved fixed.
Please feel free to reopen it if you can still reproduce the issue with current bits.
Thanks!