From fa65972201b0f97e6dd1fc9f0266208a652e2ca1 Mon Sep 17 00:00:00 2001 From: Atsushi Eno Date: Fri, 9 Dec 2016 11:42:13 +0900 Subject: [PATCH] [msbuild] Add new AndroidSkipJavacVersionCheck property. We check javac version and adjust source compatibility to 1.7 if the version is 1.8, and proguard or multidex is used (because, they are incompatible with Java8). This, being the mandatory behavior is, however, problematic. When we supply custom proguard as a NuGet package to resolve the Java8 incompatibility issue, we still expect Java8 is used (otherwise, support library applications do not compile). But the above prevents that. So, skip javac version check when AndroidSkipJavacVersionCheck property is 'True'. My facebook proguard NuGet package already has this property as true in its MSBuild props file. So you can add this in your Android 7.0+ project and enable proguard or multidex, once you get this change merged. https://www.nuget.org/packages/name.atsushieno.proguard.facebook/5.3.2.2 --- .../Tasks/AdjustJavacVersionArguments.cs | 6 ++++++ .../Xamarin.Android.Common.targets | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/AdjustJavacVersionArguments.cs b/src/Xamarin.Android.Build.Tasks/Tasks/AdjustJavacVersionArguments.cs index f3c6f8068df..3b6e979047f 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/AdjustJavacVersionArguments.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/AdjustJavacVersionArguments.cs @@ -16,6 +16,8 @@ public class AdjustJavacVersionArguments : ToolTask public bool EnableMultiDex { get; set; } + public bool SkipJavacVersionCheck { get; set; } + [Output] public string TargetVersion { get; set; } @@ -32,6 +34,10 @@ public override bool Execute () Log.LogDebugMessage ("ToolExe: {0}", ToolExe); Log.LogDebugMessage ("EnableProguard: {0}", EnableProguard); Log.LogDebugMessage ("EnableMultiDex: {0}", EnableMultiDex); + Log.LogDebugMessage ("SkipJavacVersionCheck: {0}", SkipJavacVersionCheck); + + if (SkipJavacVersionCheck) + return true; // so far only proguard matters. if (!EnableProguard && !EnableMultiDex) diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 2959b8c0dcb..a3b4842ff76 100755 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -177,7 +177,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. v$(_XAMajorVersionNumber).0 True True - + False Normal @@ -1825,6 +1825,7 @@ because xbuild doesn't support framework reference assemblies. Condition="'$(JavacTargetVersion)'=='' or '$(JavacSourceVersion)' == ''" ToolPath="$(JavacToolPath)" ToolExe="$(JavacToolExe)" + SkipJavacVersionCheck="$(AndroidSkipJavacVersionCheck)" EnableProguard="$(AndroidEnableProguard)" EnableMultiDex="$(AndroidEnableMultiDex)">