Bug 28333 - Android Project file does not reflect Android Application GUI settings
Summary: Android Project file does not reflect Android Application GUI settings
Status: CLOSED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Android Add-in ()
Version: 5.8
Hardware: PC Windows
: Normal normal
Target Milestone: master
Assignee: Greg Munn
URL:
Depends on:
Blocks:
 
Reported: 2015-03-23 10:53 UTC by Nicolò Carandini
Modified: 2015-03-27 09:03 UTC (History)
3 users (show)

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

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

Description Nicolò Carandini 2015-03-23 10:53:33 UTC
the properties
- AndroidUseLatestPlatformSdk
- TargetFrameworkVersion

of .csprj file do not reflect the settings made by a user by the "Project Options | Android Application" GUI panel. 

REPRODUCTION STEPS

1. Full install Android SDK Level 21 and Level 19

2. Open Xamarin Studio (Mac or Windows versions, they both have the same problem)

3. Create an Android Project

4. Open the Project Options | Android Application to see:

"Minimum Android version" set to "Automatic - use target framework version (API 19)"
"Target Android version" set to "Automatic - use target framework version (API 19)"

5. Check the android manifest file, that contains:

    <uses-sdk />

6. Check the .csproj file, that contains:

    <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
    <TargetFrameworkVersion>v4.4</TargetFrameworkVersion>


Because we have installed the Level 21, the values of:

- AndroidUseLatestPlatformSdk (true)
- TargetFrameworkVersion (v4.4)

are incongruent and produce an error if we try to install and run the app to a Level 19 device.

More over, continue with these other steps:

7. Open teh "Project Options | Android Application" GUI panel and change the settings to:

"Minimum Android version" set to "Override- Android 4.1 API (API level 16)"
"Target Android version" set to "Override- Android 4.4 API (API level 19)"

8. Check the android manifest file, that now correctly contains:

    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="19" />

9. Check the .csproj file, that still contains:

    <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
    <TargetFrameworkVersion>v4.4</TargetFrameworkVersion>


Where AndroidUseLatestPlatformSdk should be False, not True !

I have tested this same issue also on the Mac version of Xamarin Studio with same result.

The Visual Studio plugin has a slightly different behaviour, because it removes the True value, but don't substitute it with False, so at the end we will find:

    <AndroidUseLatestPlatformSdk>
    </AndroidUseLatestPlatformSdk>


WORKAROUND:

At the end of the day, to run the app I did set the right thing by hand on the .csproj file:

    <AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
    <TargetFrameworkVersion>v4.4</TargetFrameworkVersion>

and everything went well.

SYSTEM INFO:

=== Xamarin Studio ===

Version 5.8.1 (build 8)
Installation UUID: beba9785-d619-4ffa-b912-184639f8097d
Runtime:
	Microsoft .NET 4.0.30319.0
	GTK+ 2.24.22 (MS-Windows theme)
	GTK# 2.12.26

=== Xamarin.Android ===

Version: 4.20.0 (Business Edition)
Android SDK: C:\Program Files (x86)\Android\android-sdk
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0.3 (API level 15)
		4.4   (API level 19)
Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_55
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) Client VM (build 24.55-b03, mixed mode, sharing)

=== Xamarin Android Player ===

Not Installed

=== Build Information ===

Release ID: 508010008
Git revision: f8e52bf493869b6a320a95400553dc9ea8b7ef22
Build date: 2015-03-13 13:41:50-04
Xamarin addins: 84d611cc17567a68daad719327e90af06d2ae327

=== Operating System ===

Windows 6.2.9200.0 (64-bit)
Comment 1 Greg Munn 2015-03-23 12:40:35 UTC
Nicolo,

first up, I'd like to focus on this - 
    Version: 4.20.0 (Business Edition)
        Android SDK: C:\Program Files (x86)\Android\android-sdk
        Supported Android versions:
            2.1   (API level 7)
            2.2   (API level 8)
            2.3   (API level 10)
            3.1   (API level 12)
            4.0.3 (API level 15)
            4.4   (API level 19)

This list is literally the list of _supported_ android versions, what that means is that you have a) an installed version of Xamarin Android that supports those API levels AND b) each of those API levels have the corresponding Google SDK installed.

Since it does not list API 21, then setting latest framework will give you 4.4 / API 19.

So, what we need to determine is why there is a disparity between this list and what you're saying about having API 21 installed.

For starters, can you attach a screenshot of the Android SDK Manager, specifically highlighting the API 21 node and perhaps what was the error you received when you tried to deploy to a level 19 device?

Additionally, to help me get the correct environment, it would be helpful if you could let me know the version of Xamarin 3.xxx on Windows, or as you've tested this on Mac, the About details from the mac will do - specifically I need the full version of Xamarin Android 4.20.0.??.
Comment 2 Nicolò Carandini 2015-03-23 17:22:26 UTC
Hi Greg,

My fault!

I've downloaded the Level 22 and Level 19, not the Level 21 :-(


Now the app is able to work without any problem, but always on Level 21 SDK, not the level set on the "Project Options | Android Application" GUI panel. 


I'll write here the corrected bug description, if you like you can close this bug and I will open another, with the right description (also removing the Level 22 part, that is non consistent with Xamarin.Android 4.20.x):

--------------------
REVISED DESCRIPTION:
--------------------

The properties

- AndroidUseLatestPlatformSdk
- TargetFrameworkVersion

of .csprj file do not reflect the settings made by a user by the "Project
Options | Android Application" GUI panel. 

REPRODUCTION STEPS

1. Full install Android SDK Level 21 and 19

2. Open Xamarin Studio (Mac or Windows versions, they both have the same
problem)

3. Create an Android Project

4. Open the Project Options | Android Application to see:

"Minimum Android version" set to "Automatic - use target framework version (API
19)"
"Target Android version" set to "Automatic - use target framework version (API
19)"

5. Check the android manifest file, that contains:

    <uses-sdk />

6. Check the .csproj file, that contains:

    <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>


Because we have installed the Level 22, the values of:

- AndroidUseLatestPlatformSdk (true)
- TargetFrameworkVersion (v5.0)

are incongruent.

Ok, to be fair Xamarin 4.20 do not support SDK newer than Level 21, so I'm on the wrong side of, and the easy step is to uninstall Android SDK Level 22.

But let's continue with these other steps:

7. Open the "Project Options | Android Application" GUI panel and change the
settings to:

"Minimum Android version" set to "Override- Android 4.1 API (API level 16)"
"Target Android version" set to "Override- Android 4.4 API (API level 19)"

8. Check the android manifest file, that now correctly contains:

    <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="19" />

9. Check the .csproj file, that still contains:

    <AndroidUseLatestPlatformSdk>True</AndroidUseLatestPlatformSdk>
    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>


Where AndroidUseLatestPlatformSdk should be False, not True !

I have tested this same issue also on the Mac version of Xamarin Studio with
same result.

The Visual Studio plugin has a slightly different behaviour, because it removes
the True value, but don't substitute it with False, so at the end we will find:

    <AndroidUseLatestPlatformSdk>
    </AndroidUseLatestPlatformSdk>


WORKAROUND:

At the end of the day, to run the app I did set the right thing by hand on the
.csproj file:

    <AndroidUseLatestPlatformSdk>False</AndroidUseLatestPlatformSdk>
    <TargetFrameworkVersion>v4.4</TargetFrameworkVersion>

and everything went well.

SYSTEM INFO (Mac environment):

=== Xamarin Studio ===

Version 5.8.1 (build 8)
Installation UUID: 81e7cd91-26ab-4945-93a4-113b3350ed87
Runtime:
	Mono 3.12.1 ((detached/b63df7d)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 312010002

=== Apple Developer Tools ===

Xcode 6.2 (6776)
Build 6C131e

=== Xamarin.iOS ===

Version: 8.8.1.9 (Business Edition)
Hash: 7e1f69e
Branch: 
Build date: 2015-03-12 15:35:49-0400

=== Xamarin.Mac ===

Not Installed

=== Xamarin.Android ===

Version: 4.20.1.0 (Business Edition)
Android SDK: /Users/nick/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0.3 (API level 15)
		4.4   (API level 19)
		5.0   (API level 21)
Java SDK: /usr
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)

=== Xamarin Android Player ===

Not Installed

=== Build Information ===

Release ID: 508010008
Git revision: f8e52bf493869b6a320a95400553dc9ea8b7ef22
Build date: 2015-03-13 16:16:49-04
Xamarin addins: 84d611cc17567a68daad719327e90af06d2ae327

=== Operating System ===

Mac OS X 10.10.2
Darwin MBP-di-NICOLO.homenet.telecomitalia.it 14.1.0 Darwin Kernel Version 14.1.0
    Thu Feb 26 19:26:47 PST 2015
    root:xnu-2782.10.73~1/RELEASE_X86_64 x86_64
Comment 3 Greg Munn 2015-03-23 17:51:13 UTC
Clarification:

"Because we have installed the Level 22, the values of:

- AndroidUseLatestPlatformSdk (true)
- TargetFrameworkVersion (v5.0)

are incongruent."

do you mean to say, that because you have Google SDK 22 installed that the statement "Use Latest Platform Sdk of v5.0" is incongruent?
Comment 4 Nicolò Carandini 2015-03-23 18:07:18 UTC
Greg,
I mean that v5.0 is not the latest platform sdk available.

But let's skip the Level 22 altogether (it's my fault and I've uninstalled it) and keep focus on the bug:

now that I've uninstalled Android SDK Level 22, the warning is correct:

Warning XA4211: AndroidManifest.xml //uses-sdk/@android:targetSdkVersion '19'
is less than $(TargetFrameworkVersion) 'v5.0'. Using API-21 for ACW
compilation. (XA4211) (MyLev19App)

But now I need to manually set 

AndroidUseLatestPlatformSdk to False

and

TargetFrameworkVersion to v4.4

Only then the Warning goes away and the app is effectively built with Level 19
API.
Comment 5 Nicolò Carandini 2015-03-23 18:19:35 UTC
Uh, oh! Now I better understand what you mean, and I must ask for clarification:

What is the intended meaning of AndroidUseLatestPlatformSdk ?

Because using an override setting produce a removed "true" value in Visual Studio plugin, I thought that:

if the value of AndroidUseLatestPlatformSdk  is "True",
then the compiler will ignore the user setting of overriden API level and use the latest available platform API (that the Xamarin.Andoid code can handle), i.e. the TargetFrameworkVersion value.

if the value is "False",
then the compiler will use the overriden API level set by the user.

From your clarification request I must assume to be wrong. Can you explain me the intended use for these two parameters?

In any case, something is buggy because as a user I set the override Level 19 and unless I change the .csproj file by hand I cannot have it.
Comment 6 Greg Munn 2015-03-24 13:03:28 UTC
Hopefully this post will answer some of your questions

http://redth.codes/such-android-api-levels-much-confuse-wow/

In short, you got the warning because you changed the target sdk to one lower than the given TargetFramework and that the compiler was using the higher of the 2 versions when invoking 'aapt'. Generally you should only need to change the Target Framework and Min SDK Version.

Also, you don't have to manually edit the csproj to change the targetframework. Simply choosing any of the available frameworks will set the value and AndroidUseLatestPlatformSdk will be false.
Comment 7 Nicolò Carandini 2015-03-27 05:00:41 UTC
Hi Greg,
so sorry for the time you spent on this. No bug at all. Please close it.
Comment 8 Udham Singh 2015-03-27 09:03:05 UTC
As per comment 7, I am closing this issue. Thanks!