From a506a5d7ddb6eca3bff2515f81bf9132d5d89889 Mon Sep 17 00:00:00 2001 From: Jonathan Pryor Date: Mon, 28 Aug 2017 14:58:30 -0400 Subject: [PATCH] [Xamarin.Android.Build.Tasks] Insert newlines between types (#790) Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=59036 When building a project with `$(AndroidEnableMultiDex)`=True, an `obj/$(Configuration)/multidex.keep` file is generated, which is a list of Java classes, one per line, which should be placed into the "main" `.dex` file for the application. Unfortunately, commit 6829b7d1 results in a `multidex.keep` file which places all types onto a single line, instead of one class per line. This results in *breaking* multidex, as when this happens, nothing ensures that the required types are in the main `.dex` file, which could prevent the app from launching on the target device. Fix the `` task by always appending a newline after every type which should be preserved. --- .../Tasks/CreateMultiDexMainDexClassList.cs | 2 +- .../Tests/Xamarin.Android.Build.Tests/BuildTest.cs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/CreateMultiDexMainDexClassList.cs b/src/Xamarin.Android.Build.Tasks/Tasks/CreateMultiDexMainDexClassList.cs index 355ebfa9e97..26ffea29043 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/CreateMultiDexMainDexClassList.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/CreateMultiDexMainDexClassList.cs @@ -107,7 +107,7 @@ protected override void LogEventsFromTextOutput (string singleLine, MessageImpor var exceptionMatch = ExceptionRegEx.Match (singleLine); if (writeOutputToKeepFile && !match.Success && !exceptionMatch.Success) - File.AppendAllText (MultiDexMainDexListFile, singleLine); + File.AppendAllText (MultiDexMainDexListFile, singleLine + "\n"); base.LogEventsFromTextOutput (singleLine, messageImportance); } } 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 5fbc8f2f8c3..873a05d7bb0 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 @@ -373,6 +373,9 @@ public void BuildMultiDexApplication (bool useJackAndJill, string fxVersion) Assert.IsTrue (b.Build (proj), "Build should have succeeded."); Assert.IsTrue (File.Exists (Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "android/bin/classes.dex")), "multidex-ed classes.zip exists"); + var multidexKeepPath = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, "multidex.keep"); + Assert.IsTrue (File.Exists (multidexKeepPath), "multidex.keep exists"); + Assert.IsTrue (File.ReadAllLines (multidexKeepPath).Length > 1, "multidex.keep must contain more than one line."); Assert.IsTrue (b.LastBuildOutput.Contains (Path.Combine (fxVersion, "mono.android.jar")), fxVersion + "/mono.android.jar should be used."); } }