From ce3d766901d1e0e0352067ba6a03657e2a8b912e Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Fri, 3 Nov 2017 09:43:06 -0500 Subject: [PATCH] [tests] workaround broken lint.bat on Windows Context in #992 The lint.bat tool installed to ~\android-toolchain\sdk\tools\bin appears to be broken on Windows, so a few tests are failing that use it. There is a workaround to set the `JAVA_OPTS` environment variable that gets these tests passing on Windows. Hopefully, this is a temporary workaround until a new version of the SDK tools comes out that fixes this issue. One other thing to note here is that the Android SDK installed by Visual Studio uses the SDK tools version 25.x, which does not appear to have this issue on windows. --- .../Xamarin.Android.Build.Tests/BuildTest.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index 99d06e97979..697d4f64884 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -890,9 +890,26 @@ public void DuplicateValuesInResourceCaseMap () } } + /// + /// Works around a bug in lint.bat on Windows: https://issuetracker.google.com/issues/68753324 + /// - We may want to remove this if a future Android SDK tools, no longer has this issue + /// + void FixLintOnWindows () + { + if (Environment.OSVersion.Platform == PlatformID.Win32NT) { + var userProfile = Environment.GetFolderPath (Environment.SpecialFolder.UserProfile); + var androidSdkTools = Path.Combine (userProfile, "android-toolchain", "sdk", "tools"); + if (Directory.Exists (androidSdkTools)) { + Environment.SetEnvironmentVariable ("JAVA_OPTS", $"\"-Dcom.android.tools.lint.bindir={androidSdkTools}\"", EnvironmentVariableTarget.Process); + } + } + } + [Test] public void CheckLintErrorsAndWarnings () { + FixLintOnWindows (); + var proj = new XamarinAndroidApplicationProject (); proj.UseLatestPlatformSdk = true; proj.SetProperty ("AndroidLintEnabled", true.ToString ()); @@ -917,6 +934,8 @@ public class MainActivity : Activity [Test] public void CheckLintConfigMerging () { + FixLintOnWindows (); + var proj = new XamarinAndroidApplicationProject (); proj.SetProperty ("AndroidLintEnabled", true.ToString ()); proj.OtherBuildItems.Add (new AndroidItem.AndroidLintConfig ("lint1.xml") {