Bug 57692 - Encountering build error when android-26/android.jar is installed and AndroidUseLatestPlatformSdk is true
Summary: Encountering build error when android-26/android.jar is installed and Android...
Status: VERIFIED FIXED
Alias: None
Product: Android
Classification: Xamarin
Component: MSBuild ()
Version: 7.4 (15.3)
Hardware: PC Windows
: High major
Target Milestone: 15.3
Assignee: dean.ellis
URL:
Depends on:
Blocks:
 
Reported: 2017-06-22 15:47 UTC by Gonzalo Martin
Modified: 2017-07-20 08:46 UTC (History)
6 users (show)

Tags: Shiproom
Is this bug a regression?: Yes
Last known good build: d15-2

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:
VERIFIED FIXED

Description Gonzalo Martin 2017-06-22 15:47:37 UTC
Running BasicCalculator sample, I'm getting a compilation error when I build it.

##### Steps to reproduce #####
1. Download https://github.com/xamarin/mobile-samples/tree/master/LivePlayer/BasicCalculator
2. Open VS2017
3. Build solution or Build Calculator.Droid project

##### Expected result #####
The solution/project built fine

##### Current result #####
I'm getting the following error:

> Severity    Code    Description    Project    File    Line    Suppression State
> Error        Could not find android.jar for API Level 26. This means the Android SDK platform for API Level 26 is not installed. Either install it in the Android SDK Manager (Tools > Open Android SDK Manager...), or change your Xamarin.Android project to target an API version that is installed. (%PATH_TO_ANDROID_HOME%\platforms\android-O\android.jar missing.)    Calculator.Droid

##### Suplemental Info #####
XA version: 7.4.0.2
Environment info: https://gist.github.com/gonzalonm/a4590eda2b7b5d7a4cbe10b7a808079c
Screencast: http://www.screencast.com/t/SKwK4kL7s
Comment 1 Gonzalo Martin 2017-06-23 12:19:23 UTC
One more thing, it's not happening on d15-2. In addition, it's reproducible on both Mac and Windows for d15-3. Changing 'Target Milestone' to d15-3
Comment 2 Gonzalo Martin 2017-06-23 14:44:52 UTC
Last update on this: To avoid this problem, we should remove API26 for now.
Comment 3 Jon Douglas [MSFT] 2017-06-27 20:25:48 UTC
I am CONFIRMING this bug because the path is incorrect on lookup. For example, here is another similar error message:

Could not find android.jar for API Level 26. This means the Android SDK platform for API Level 26 is not installed. Either install it in the Android SDK Manager (Tools > Open Android SDK Manager...), or change your Xamarin.Android project to target an API version that is installed. (C:\Android\android-sdk\platforms\android-O\android.jar missing.)	Calculator.Droid	C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets	541	

The problem here is that the lookup is for "android-O". I believe Google has changed this to "android-26" now that the API is in a second beta. I believe this needs to be reflected in Xamarin.Android.

As a workaround, you could technically copy  the "android-26" folder and rename to "android-O" which will succeed the use case you have.
Comment 4 dean.ellis 2017-06-28 10:24:42 UTC
I believe this is fixed in master already and should also be fixed as it seems to work ok on master. I'm not 100% sure which fixes are needed though. [1] does not appear to be in the d15-3 branch, and there might be others.

[1] xamarin-android/master/2745b6a8
Comment 5 dean.ellis 2017-06-28 12:45:24 UTC
Other related commits

xamarin-android/master/f4901216
Comment 6 Jérémie Laval 2017-06-29 15:47:25 UTC
The side-effect of this bug is also that project set to use the latest API available will pick up 26 as the version if android-26 is installed (now available in the stable channel so easily installable by users) and thus trigger this issue on build.
Comment 9 Adrian Murphy 2017-07-05 21:46:40 UTC
Disregard the above comment.

Dean - Is this fix appropriate to ship to everyone for 15.3, or can it wait until API 26 ships?
Comment 10 dean.ellis 2017-07-06 18:10:46 UTC
I have a work around for now

https://gist.github.com/dellis1972/77b1df1e1652fcda495e9371496992b6

The idea is if we find an API level which is above what we currently support we just use the max supported value.
Comment 11 dean.ellis 2017-07-06 18:33:11 UTC
PR is up https://github.com/xamarin/xamarin-android/pull/688
Comment 12 dean.ellis 2017-07-11 10:19:59 UTC
Fixed in Xamarin-android/master/ad56f8ae
Comment 13 Peter Collins 2017-07-13 18:13:15 UTC
Confirmed the issue using:
> VS Version 15.3.0 Preview 3.0
> Xamarin.Android SDK   7.4.0.2 (5a73b38)
The issue is no longer reproducible with:
> VS Version 15.3.0 Preview 3.0
> Xamarin.Android SDK   7.4.99.49 (master/42ec1af)
Comment 14 Peter Collins 2017-07-17 21:36:08 UTC
Verified fixed in monodroid/d15-3/ebbee99b and VS Version 15.3.0 Preview 4.0 /
Xamarin.Android SDK   7.4.0.17 (ebbee99)
Comment 15 Adam Patridge [MSFT] 2017-07-19 15:00:12 UTC
Until this lands, I can confirm Jon's workaround of copying the `android-26` SDK platform and renaming it `android-o`. In my case, it looks like the SDK platforms were in `C:\Program Files (x86)\Android\android-sdk\platforms\`, though.

Unfortunately, completely uninstalling API 26 and/or changing the target SDK version did not resolve this for me. Even with API 26 gone and not targeted, it would still present that deployment error about API 26.
Comment 16 dean.ellis 2017-07-20 08:46:49 UTC
Adam,

After removing API 26 from disk you would probably need to clean and build since we cache a bunch of items to help speed up the builds.