From 522d7fb61f3669d85d077ba4f2889dbe8c9c8ac3 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 13 Apr 2021 20:19:00 -0500 Subject: [PATCH 1/3] Revert "[One .NET] $(AndroidEnablePreloadAssemblies)=False by default" (#5811) Context: https://github.com/xamarin/xamarin-android/issues/5838 This reverts commit d13d0f972a4eb663251b2a6b5a934c59a6789db1. Commit d13d0f97 inadvertently broke the [`DebuggingTest.ClassLibraryMainLauncherRuns()` unit test][0], when using a test app which: 1. Uses .NET 6, which -- because of d13d0f97 -- sets `$(AndroidEnablePreloadAssemblies)`=False by default -- with- 2. A "Debug" build (Fast Deployment enabled), with- 3. `$(AndroidLinkResources)`=False (the default; see also 9e6ce03), and- 4. launching the app, which 5. Loads an `Activity` subclass located in an assembly which is *not* the "main" App assembly then the app crashes during process startup: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object at MyLibrary.MainActivity.OnCreate(Bundle bundle) at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_(IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) at com.xamarin.classlibrarymainlauncherruns.MainActivity.n_onCreate(Native Method) at com.xamarin.classlibrarymainlauncherruns.MainActivity.onCreate(MainActivity.java:29) The cause of the crash is that, because not all assemblies are loaded as part of process startup -- the whole *point* to d13d0f97 and defaulting `$(AndroidEnablePreloadAssemblies)`=False -- then [`ResourceIdManager.UpdateIdValues()`][1] isn't able to update all fields in all `Resource` types to have the values from the app's `Resource.designer.cs` file. Consequently, the values *may* be invalid, and thus the `NullReferenceException`. As an "immediate" fix is not quickly forthcoming -- though enabling `$(AndroidLinkResources)`=False *by default* is an "interesting" solution, with unknown inner dev loop performance implications -- we're reverting commit d13d0f97. Issue #5838 will track the re-enabling of `$(AndroidEnablePreloadAssemblies)`=False by default in .NET 6 apps. ~~~ Additionally, update `DebuggingTest.ClassLibraryMainLauncherRuns()` so that `Resources\layout\foo.xml` contains *valid* layout XML. It was originally: which would crash with: Java.Lang.RuntimeException: Unable to start activity ComponentInfo{com.xamarin.classlibrarymainlauncherruns/com.xamarin.classlibrarymainlauncherruns.MainActivity}: android.view.InflateException: Binary XML file line #1 in com.xamarin.classlibrarymainlauncherruns:layout/foo: Binary XML file line #1: You must supply a layout_width attribute. ---> Android.Views.InflateException: Binary XML file line #1 in com.xamarin.classlibrarymainlauncherruns:layout/foo: Binary XML file line #1: You must supply a layout_width attribute. ---> Java.Lang.UnsupportedOperationException: Binary XML file line #1: You must supply a layout_width attribute. --- End of managed Java.Lang.UnsupportedOperationException stack trace --- java.lang.UnsupportedOperationException: Binary XML file line #1: You must supply a layout_width attribute. because the layout XML was, in fact, invalid, as it wasn't providing the required `android:layout_width` attribute. Update `foo.xml` so that it has valid layout XML: " This way we won't be chasing invalid XML going forward. The above `UnsupportedOperationException` *hid* the `NullReferenceException` in d13d0f97; the `NullReferenceException` wasn't visible until after the invalid XML was fixed. [0]: https://github.com/xamarin/xamarin-android/blob/bf4f4f42af26cdddb46087deed59aae8424f7942/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs#L74-L124 [1]: https://github.com/xamarin/xamarin-android/blob/bf4f4f42af26cdddb46087deed59aae8424f7942/src/Mono.Android/Android.Runtime/ResourceIdManager.cs#L9-L31 --- .../Tests/Xamarin.Android.Build.Tests/BuildTest.cs | 6 +----- .../Xamarin.Android.Common.targets | 3 +-- tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs | 8 +++++++- 3 files changed, 9 insertions(+), 8 deletions(-) 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 c08b20db66d..c0627aa7823 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 @@ -3932,11 +3932,7 @@ public void PackageNamingPolicy ([Values ("LowercaseMD5", "LowercaseCrc64")] str Assert.IsTrue (b.Build (proj), "build should have succeeded."); var environment = b.Output.GetIntermediaryPath (Path.Combine ("__environment__.txt")); FileAssert.Exists (environment); - if (Builder.UseDotNet) { - Assert.AreEqual ($"__XA_PACKAGE_NAMING_POLICY__={packageNamingPolicy}{Environment.NewLine}mono.enable_assembly_preload=0", File.ReadAllText (environment).Trim ()); - } else { - Assert.AreEqual ($"__XA_PACKAGE_NAMING_POLICY__={packageNamingPolicy}", File.ReadAllText (environment).Trim ()); - } + Assert.AreEqual ($"__XA_PACKAGE_NAMING_POLICY__={packageNamingPolicy}", File.ReadAllText (environment).Trim ()); } } diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index a9fcc31f1ce..f64b08aa6eb 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -290,8 +290,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. False - <_AndroidEnablePreloadAssembliesDefault Condition=" '$(UsingAndroidNETSdk)' == 'true' ">False - <_AndroidEnablePreloadAssembliesDefault Condition=" '$(UsingAndroidNETSdk)' != 'true' ">True + <_AndroidEnablePreloadAssembliesDefault>True $(_AndroidEnablePreloadAssembliesDefault) <_NativeAssemblySourceDir>$(IntermediateOutputPath)android\ <_AndroidUseNewTypemaps>True diff --git a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs index 0f4ef9f7a3e..fc8d59df683 100755 --- a/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs +++ b/tests/MSBuildDeviceIntegration/Tests/DebuggingTest.cs @@ -102,7 +102,13 @@ public void ClassLibraryMainLauncherRuns () // Remove the default MainActivity.cs & AndroidResources app.AndroidResources.Clear (); app.AndroidResources.Add (new AndroidItem.AndroidResource ("Resources\\layout\\foo.xml") { - TextContent = () => "" + TextContent = () => +@" +" }); app.Sources.Remove (app.GetItem ("MainActivity.cs")); From b36df8fbeb15bcc2bcbe239d7ce49f8ec93ad263 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Wed, 14 Apr 2021 09:24:51 -0500 Subject: [PATCH 2/3] [One .NET] fix $(PackageTargetFallback) and $(TargetPlatformVersion) (#5835) Fixes: https://github.com/xamarin/xamarin-android/issues/5819 A project using Maui and `TargetFramework=net6.0-android` can hit the warning: warning CA1416: This call site is reachable on all platforms. 'Class1' is only supported on: 'android' 30.0 and later. I found the project had: TargetPlatformVersion = 30 Projects that emit no warnings have `TargetPlatformVersion = 30.0`. Update the `` MSBuild task to always append `.0`: version.ApiLevel.ToString ("0.0", CultureInfo.InvariantCulture) This solves the warning, but we still get an error in other projects in the solution: error CS1061: 'Class1' does not contain a definition for 'Context' and no accessible extension method 'Context' accepting a first argument of type 'Class1' could be found (are you missing a using directive or an assembly reference?) The build used: ~\.nuget\packages\microsoft.maui.core\6.0.100-preview.3.269\lib\netstandard2.1\Microsoft.Maui.dll Instead of: ~\.nuget\packages\microsoft.maui.core\6.0.100-preview.3.269\lib\net6.0-android30.0\Microsoft.Maui.dll I found this project uses `TargetFramework=net6.0-android30.0`, which resulted in a weird value for `$(PackageTargetFallback)`: PackageTargetFallback = net6.0-android30.0.0; monoandroid12.0; monoandroid11.0; monoandroid10.0; monoandroid90; monoandroid81; monoandroid80; monoandroid70; monoandroid60; monoandroid50; To fix this, I conditionally added the `.0` and the project builds successfully. We will hopefully be able to remove usage of `$(PackageTargetFallback)` soon, as it was a workaround until NuGet has official support for .NET 6 & MonoAndroid target frameworks. I added a new test that covers these cases. I also added a new `AssertHasNoWarnings()` extension method to simplify checking for warnings. I also updated a couple tests that no longer emit warnings. --- .../GenerateSupportedPlatforms.cs | 5 ++- .../Microsoft.Android.Sdk.NuGet.targets | 4 +- .../Xamarin.Android.Build.Tests/BuildTest.cs | 9 ++-- .../PackagingTest.cs | 14 +------ .../Utilities/AssertionExtensions.cs | 12 ++++++ .../Xamarin.Android.Build.Tests/XASdkTests.cs | 42 +++++++++++++++++-- 6 files changed, 62 insertions(+), 24 deletions(-) diff --git a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/GenerateSupportedPlatforms.cs b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/GenerateSupportedPlatforms.cs index 6d91f3c8db4..fb491f744dc 100644 --- a/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/GenerateSupportedPlatforms.cs +++ b/build-tools/Xamarin.Android.Tools.BootstrapTasks/Xamarin.Android.Tools.BootstrapTasks/GenerateSupportedPlatforms.cs @@ -1,4 +1,5 @@ using System.IO; +using System.Globalization; using System.Linq; using System.Xml; using Microsoft.Build.Framework; @@ -61,7 +62,7 @@ public override bool Execute () writer.WriteEndElement (); // writer.WriteStartElement ("TargetPlatformVersion"); writer.WriteAttributeString ("Condition", " '$(TargetPlatformVersion)' == '' "); - writer.WriteString (versions.MaxStableVersion.ApiLevel.ToString ()); + writer.WriteString (versions.MaxStableVersion.ApiLevel.ToString ("0.0", CultureInfo.InvariantCulture)); writer.WriteEndElement (); // writer.WriteEndElement (); // @@ -70,7 +71,7 @@ public override bool Execute () .Where (v => v.ApiLevel >= MinimumApiLevel) .OrderBy (v => v.ApiLevel)) { writer.WriteStartElement ("AndroidSdkSupportedTargetPlatformVersion"); - writer.WriteAttributeString ("Include", version.ApiLevel.ToString ()); + writer.WriteAttributeString ("Include", version.ApiLevel.ToString ("0.0", CultureInfo.InvariantCulture)); writer.WriteEndElement (); // } writer.WriteStartElement ("SdkSupportedTargetPlatformVersion"); diff --git a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NuGet.targets b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NuGet.targets index 7af0c024c0e..bcb1ca02c7e 100644 --- a/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NuGet.targets +++ b/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NuGet.targets @@ -12,6 +12,8 @@ This file contains *temporary* workarounds for NuGet in .NET 5. + <_AndroidPlatformVersion>$(TargetPlatformVersion) + <_AndroidPlatformVersion Condition=" !$(_AndroidPlatformVersion.EndsWith ('.0')) ">$(_AndroidPlatformVersion).0 - net6.0-android$(TargetPlatformVersion).0; + net6.0-android$(_AndroidPlatformVersion); monoandroid12.0; monoandroid11.0; monoandroid10.0; 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 c0627aa7823..ac30b0301a5 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 @@ -177,7 +177,7 @@ public void BuildHasNoWarnings (bool isRelease, bool xamarinForms, bool multidex } using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, " 0 Warning(s)"), "Should have no MSBuild warnings."); + b.AssertHasNoWarnings (); Assert.IsFalse (StringAssertEx.ContainsText (b.LastBuildOutput, "Warning: end of file not at end of a line"), "Should not get a warning from the task."); var lockFile = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath, ".__lock"); @@ -195,7 +195,7 @@ public void ClassLibraryHasNoWarnings () proj.SetProperty ("AndroidEnableMultiDex", "true"); using (var b = CreateDllBuilder ()) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); - Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, " 0 Warning(s)"), "Should have no MSBuild warnings."); + b.AssertHasNoWarnings (); // $(AndroidEnableMultiDex) should not add android-support-multidex.jar! if (Builder.UseDotNet) { @@ -4066,10 +4066,7 @@ public void XA4310 ([Values ("apk", "aab")] string packageFormat) StringAssertEx.Contains ("error XA4310", builder.LastBuildOutput, "Error should be XA4310"); StringAssertEx.Contains ("`DoesNotExist`", builder.LastBuildOutput, "Error should include the name of the nonexistent file"); - if (!Builder.UseDotNet) { - // ILLink produces lots of warnings in .NET 5+ - StringAssertEx.Contains ("0 Warning(s)", builder.LastBuildOutput, "Should have no MSBuild warnings."); - } + builder.AssertHasNoWarnings (); } } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs index 1c6fb9a7f93..c0b124f20db 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs @@ -396,12 +396,7 @@ public void CheckSignApk ([Values(true, false)] bool useApkSigner, [Values(true, using (var b = CreateApkBuilder (Path.Combine ("temp", TestContext.CurrentContext.Test.Name))) { var bin = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath); Assert.IsTrue (b.Build (proj), "First build failed"); - if (!Builder.UseDotNet) { - // In .NET 5+, there are ILLink warnings - Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, " 0 Warning(s)"), - "First build should not contain warnings! Contains\n" + - string.Join ("\n", b.LastBuildOutput.Where (line => line.Contains ("warning")))); - } + b.AssertHasNoWarnings (); //Make sure the APKs are signed foreach (var apk in Directory.GetFiles (bin, "*-Signed.apk")) { @@ -425,12 +420,7 @@ public void CheckSignApk ([Values(true, false)] bool useApkSigner, [Values(true, item.TextContent = () => proj.StringsXml.Replace ("${PROJECT_NAME}", "Foo"); item.Timestamp = null; Assert.IsTrue (b.Build (proj), "Second build failed"); - if (!Builder.UseDotNet) { - // In .NET 5+, there are ILLink warnings - Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, " 0 Warning(s)"), - "Second build should not contain warnings! Contains\n" + - string.Join ("\n", b.LastBuildOutput.Where (line => line.Contains ("warning")))); - } + b.AssertHasNoWarnings (); //Make sure the APKs are signed foreach (var apk in Directory.GetFiles (bin, "*-Signed.apk")) { diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/AssertionExtensions.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/AssertionExtensions.cs index b51a4608d6c..740bb880c4e 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/AssertionExtensions.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/AssertionExtensions.cs @@ -89,5 +89,17 @@ public static void AssertEntryContents (this ZipArchive zip, string zipPath, str Assert.AreEqual (contents, actual, $"{archivePath} should contain {contents}"); } } + + [DebuggerHidden] + public static void AssertHasNoWarnings (this ProjectBuilder builder) + { + Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, " 0 Warning(s)"), $"{builder.BuildLogFile} should have no MSBuild warnings."); + } + + [DebuggerHidden] + public static void AssertHasNoWarnings (this DotNetCLI dotnet) + { + Assert.IsTrue (StringAssertEx.ContainsText (dotnet.LastBuildOutput, " 0 Warning(s)"), $"{dotnet.BuildLogFile} should have no MSBuild warnings."); + } } } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs index 6f8b305dc9d..48c5cda07cf 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/XASdkTests.cs @@ -392,8 +392,7 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease) var dotnet = CreateDotNetBuilder (proj); Assert.IsTrue (dotnet.Build (), "`dotnet build` should succeed"); - - Assert.IsTrue (StringAssertEx.ContainsText (dotnet.LastBuildOutput, " 0 Warning(s)"), "Should have no MSBuild warnings."); + dotnet.AssertHasNoWarnings (); var outputPath = Path.Combine (FullProjectDirectory, proj.OutputPath); var intermediateOutputPath = Path.Combine (FullProjectDirectory, proj.IntermediateOutputPath); @@ -460,7 +459,7 @@ public void DotNetBuildXamarinForms () var proj = new XamarinFormsXASdkProject (); var dotnet = CreateDotNetBuilder (proj); Assert.IsTrue (dotnet.Build (), "`dotnet build` should succeed"); - Assert.IsTrue (StringAssertEx.ContainsText (dotnet.LastBuildOutput, " 0 Warning(s)"), "Should have no MSBuild warnings."); + dotnet.AssertHasNoWarnings (); } [Test] @@ -554,6 +553,43 @@ public void XamarinLegacySdk () nupkg.AssertContainsEntry (nupkgPath, $"lib/{legacyTargetFramework}/{proj.ProjectName}.dll"); } + [Test] + public void MauiTargetFramework ([Values ("net6.0-android", "net6.0-android30", "net6.0-android30.0")] string targetFramework) + { + var library = new XASdkProject (outputType: "Library") { + TargetFramework = targetFramework, + }; + library.ExtraNuGetConfigSources.Add ("https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json"); + library.Sources.Clear (); + library.Sources.Add (new BuildItem.Source ("Foo.cs") { + TextContent = () => +@"using Microsoft.Maui; +using Microsoft.Maui.Handlers; + +public abstract class Foo : AbstractViewHandler + where TVirtualView : class, IView +#if ANDROID + where TNativeView : Android.Views.View +#else + where TNativeView : class +#endif +{ + protected Foo (PropertyMapper mapper) : base(mapper) + { +#if ANDROID + var t = this.Context; +#endif + } +}", + }); + + library.PackageReferences.Add (new Package { Id = "Microsoft.Maui.Core", Version = "6.0.100-preview.3.269" }); + + var dotnet = CreateDotNetBuilder (library); + Assert.IsTrue (dotnet.Build (), $"{library.ProjectName} should succeed"); + dotnet.AssertHasNoWarnings (); + } + [Test] public void DotNetIncremental () { From 99273de949d55096ef243fe4a6ab84912c449c5f Mon Sep 17 00:00:00 2001 From: Peter Collins Date: Wed, 14 Apr 2021 12:54:47 -0400 Subject: [PATCH 3/3] [Xamarin.Android.Build.Tasks] Add $(UseInterpreter) (#5839) Fixes: https://github.com/xamarin/xamarin-android/issues/5824 Context: https://github.com/mono/mono/issues/19669 A new `$(UseInterpreter)` property has been added to toggle the existing `$(AndroidUseInterpreter)` setting. This new property does not contain OS / Platform information so that it can be used by multi-targeted projects. The `` task no longer needs to check the list of supported ABIs when the interpreter is enabled. The interpreter should now work with all architectures. I ran the .NET 6 version of the new test on an x86 emulator locally and the app launched successfully. There was also an oversight in the legacy targets that caused interpreter builds to fail with the following, which has been fixed: (_BuildApkEmbed target) -> C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2010,3): error XABLD7028: System.IO.FileNotFoundException: Could not find file 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\lib\interpreter-arm64-v8a\libxa-internal-api.so'. C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2010,3): error XABLD7028: File name: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\lib\interpreter-arm64-v8a\libxa-internal-api.so' --- .external | 2 +- Documentation/guides/messages/README.md | 1 - Documentation/guides/messages/xa0124.md | 18 ---------- .../Properties/Resources.resx | 3 -- .../Properties/xlf/Resources.cs.xlf | 5 --- .../Properties/xlf/Resources.de.xlf | 5 --- .../Properties/xlf/Resources.es.xlf | 5 --- .../Properties/xlf/Resources.fr.xlf | 5 --- .../Properties/xlf/Resources.it.xlf | 5 --- .../Properties/xlf/Resources.ja.xlf | 5 --- .../Properties/xlf/Resources.ko.xlf | 5 --- .../Properties/xlf/Resources.pl.xlf | 5 --- .../Properties/xlf/Resources.pt-BR.xlf | 5 --- .../Properties/xlf/Resources.ru.xlf | 5 --- .../Properties/xlf/Resources.tr.xlf | 5 --- .../Properties/xlf/Resources.zh-Hans.xlf | 5 --- .../Properties/xlf/Resources.zh-Hant.xlf | 5 --- .../Tasks/BuildApk.cs | 10 ------ .../Xamarin.Android.Common.targets | 2 +- .../Xamarin.Android.Legacy.targets | 4 +-- .../Tests/InstallAndRunTests.cs | 36 +++++++++++++++++++ 21 files changed, 40 insertions(+), 101 deletions(-) delete mode 100644 Documentation/guides/messages/xa0124.md diff --git a/.external b/.external index 821ffb60ba9..274f7b0c3f3 100644 --- a/.external +++ b/.external @@ -1,2 +1,2 @@ -xamarin/monodroid:main@78f627984b173e09054b86a58fcba8fd3b998be9 +xamarin/monodroid:main@45abd3f98d221a75c2d425ed94f2b6b31b8778d3 mono/mono:2020-02@eb4c3116ebf3ac44f72232fc9315fa4947c04b44 diff --git a/Documentation/guides/messages/README.md b/Documentation/guides/messages/README.md index 54dcee9c8dd..42decb96a80 100644 --- a/Documentation/guides/messages/README.md +++ b/Documentation/guides/messages/README.md @@ -68,7 +68,6 @@ ms.date: 01/24/2020 + [XA0121](xa0121.md): Assembly '{assembly}' is using '[assembly: Java.Interop.JavaLibraryReferenceAttribute]', which is no longer supported. Use a newer version of this NuGet package or notify the library author. + [XA0122](xa0122.md): Assembly '{assembly}' is using a deprecated attribute '[assembly: Java.Interop.DoNotPackageAttribute]'. Use a newer version of this NuGet package or notify the library author. + XA0123: Removing {issue} from {propertyName}. Lint {version} does not support this check. -+ [XA0124](xa0124.md): Interpreter is not supported by the x86 ABI + [XA0125](xa0125.md): `{Project}` is using a deprecated debug information level. Set the debugging information to Portable in the Visual Studio project property pages or edit the project file in a text editor and set the 'DebugType' MSBuild property to 'portable' to use the newer, cross-platform debug information level. If this file comes from a NuGet package, update to a newer version of the NuGet package or notify the library author. diff --git a/Documentation/guides/messages/xa0124.md b/Documentation/guides/messages/xa0124.md deleted file mode 100644 index f9fb4591884..00000000000 --- a/Documentation/guides/messages/xa0124.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: Xamarin.Android error XA0124 -description: XA0124 error code -ms.date: 04/28/2020 ---- -# Xamarin.Android error XA0124 - -## Issue - -Mono Interpreter does not support running on x86 devices. - -## Solution - -When attempting to use the interpreter, please make sure to disable -the `x86` target by removing it from the `$(AndroidSupportedAbis)` -MSBuild property in your project file. This can be done conditionally -**only** when using the interpreter. - diff --git a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx index 512d83fdaa3..85b877827ce 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx +++ b/src/Xamarin.Android.Build.Tasks/Properties/Resources.resx @@ -307,9 +307,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - '{0}' is using a deprecated debug information level. Set the debugging information to Portable in the Visual Studio project property pages or edit the project file in a text editor and set the 'DebugType' MSBuild property to 'portable' to use the newer, cross-platform debug information level. diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.cs.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.cs.xlf index 6512e839176..2148b4cabee 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.cs.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.cs.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - x86 ABI nepodporuje interpret. - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} Při parsování {0} došlo k problému. Pravděpodobnou příčinou je neúplný nebo neplatný kód XML. Výjimka: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.de.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.de.xlf index 78e6228bb7c..757c9ddeeab 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.de.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.de.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - Der Interpreter wird von der x86-ABI nicht unterstützt. - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} Problem beim Analysieren von "{0}". Dies ist wahrscheinlich auf eine unvollständige oder ungültige XML-Datei zurückzuführen. Ausnahme: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.es.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.es.xlf index 0e9017dc780..e340a559012 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.es.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.es.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - ABI x86 no admite el intérprete - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} Hubo un problema al analizar {0}. Probablemente se deba a un elemento XML incompleto o no válido. Excepción: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.fr.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.fr.xlf index 11e112254a6..d6fae7ae8c2 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.fr.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.fr.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - L'interpréteur n'est pas pris en charge par l'ABI x86 - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} Un problème s'est produit durant l'analyse de {0}. Cela est probablement dû à du code XML incomplet ou non valide. Exception : {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.it.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.it.xlf index b39ce8c3630..4c40102a790 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.it.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.it.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - L'interprete non è supportato dall'ABI x86 - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} Si è verificato un problema durante l'analisi di {0}, probabilmente a causa di codice XML incompleto o non valido. Eccezione: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ja.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ja.xlf index 7b2298e074c..365f133692d 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ja.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ja.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - インタープリターは x86 ABI ではサポートされていません - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} {0} の解析で問題が発生しました。不完全または無効な XML が原因である可能性があります。例外: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ko.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ko.xlf index e577d85f884..ea47518f928 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ko.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ko.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - 인터프리터는 x86 ABI에서 지원되지 않습니다. - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} {0}을(를) 구문 분석하는 중 문제가 발생했습니다. XML이 불완전하거나 잘못된 것 같습니다. 예외: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pl.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pl.xlf index 8fde2624c38..29603dfb344 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pl.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pl.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - Interpreter nie jest obsługiwany przez interfejs ABI x86 - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} Wystąpił problem podczas analizowania pliku {0}. Prawdopodobnie jest to spowodowane niekompletnym lub nieprawidłowym kodem XML. Wyjątek: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pt-BR.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pt-BR.xlf index 556cbdc4a7a..23c49ef9b05 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pt-BR.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.pt-BR.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - O interpretador não é compatível com a ABI x86 - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} Ocorreu um problema ao analisar {0}. Isso provavelmente se deve a XML incompleto ou inválido. Exceção: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ru.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ru.xlf index de02a2e6a50..b5bd580229f 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ru.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.ru.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - ABI x86 не поддерживает интерпретатор - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} Возникла проблема при синтаксическом анализе {0}. Возможная причина: неполный или недопустимый код XML. Исключение: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.tr.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.tr.xlf index 57016ac3567..dd7410dfeee 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.tr.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.tr.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - Yorumlayıcı, x86 ABI tarafından desteklenmiyor - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} {0} ayrıştırılırken bir sorun oluştu. Bunun nedeni büyük olasılıkla tamamlanmamış veya geçersiz XML olabilir. Özel durum: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hans.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hans.xlf index 6ed753343bb..20f031ab488 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hans.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hans.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - X86 ABI 不支持解释程序 - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} 分析 {0} 时出现问题。这可能是由于 XML 不完整或无效。异常: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hant.xlf b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hant.xlf index 74d7effeda8..a5dcf86e75d 100644 --- a/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hant.xlf +++ b/src/Xamarin.Android.Build.Tasks/Properties/xlf/Resources.zh-Hant.xlf @@ -294,11 +294,6 @@ When it appears in the middle of a sentence, "lint" is not capitalized. {1} - The literal name of the MSBuild property {2} - The lint version number - - Interpreter is not supported by the x86 ABI - x86 ABI 不支援解譯器 - - There was a problem parsing {0}. This is likely due to incomplete or invalid XML. Exception: {1} 剖析 {0} 時發生問題。此情況可能是 XML 不完整或無效所致。例外狀況: {1} diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs b/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs index 17d511bccad..2ef9b1770f5 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs @@ -80,7 +80,6 @@ public class BuildApk : AndroidTask public string TlsProvider { get; set; } public string UncompressedFileExtensions { get; set; } - public bool InterpreterEnabled { get; set; } // Make it required after https://github.com/xamarin/monodroid/pull/1094 is merged //[Required] @@ -121,15 +120,6 @@ protected virtual void FixupArchive (ZipArchiveEx zip) { } void ExecuteWithAbi (string [] supportedAbis, string apkInputPath, string apkOutputPath, bool debug, bool compress, IDictionary compressedAssembliesInfo) { - if (InterpreterEnabled) { - foreach (string abi in supportedAbis) { - if (String.Compare ("x86", abi, StringComparison.OrdinalIgnoreCase) == 0) { - Log.LogCodedError ("XA0124", Properties.Resources.XA0124); - return; - } - } - } - ArchiveFileList files = new ArchiveFileList (); bool refresh = true; if (apkInputPath != null && File.Exists (apkInputPath) && !File.Exists (apkOutputPath)) { diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index f64b08aa6eb..9aadfd79f40 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -159,6 +159,7 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. <_XAMajorVersionNumber>1 <_XASupportsFastDev Condition=" Exists ('$(MSBuildThisFileDirectory)Xamarin.Android.Common.Debugging.targets') ">True <_XASupportsFastDev Condition=" '$(_XASupportsFastDev)' == '' ">False + $(UseInterpreter) False false False @@ -2032,7 +2033,6 @@ because xbuild doesn't support framework reference assemblies. LibraryProjectJars="@(ExtractedJarImports)" TlsProvider="$(AndroidTlsProvider)" UncompressedFileExtensions="$(AndroidStoreUncompressedFileExtensions)" - InterpreterEnabled="$(AndroidUseInterpreter)" ProjectFullPath="$(MSBuildProjectFullPath)" IncludeWrapSh="$(AndroidIncludeWrapSh)" CheckedBuild="$(_AndroidCheckedBuild)"> diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Legacy.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Legacy.targets index 4c6c467cd6b..57fde8ee8fb 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Legacy.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Legacy.targets @@ -519,8 +519,8 @@ projects. .NET 5 projects will not import this file. - - + + diff --git a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs index 2a293e48e57..3fdb8ab61c2 100644 --- a/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/InstallAndRunTests.cs @@ -542,5 +542,41 @@ public override Type BindToType (string assemblyName, string typeName) return line.Contains ("TestJsonDeserializationCreatesJavaHandle"); }, Path.Combine (Root, builder.ProjectDirectory, "startup-logcat.log"), 45), $"Output did contain TestJsonDeserializationCreatesJavaHandle!"); } + + [Test] + public void RunWithInterpreterEnabled ([Values (false, true)] bool isRelease) + { + AssertHasDevices (); + + proj = new XamarinAndroidApplicationProject () { + IsRelease = isRelease, + }; + var abis = new string[] { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" }; + proj.SetAndroidSupportedAbis (abis); + proj.SetProperty (proj.CommonProperties, "UseInterpreter", "True"); + builder = CreateApkBuilder (); + Assert.IsTrue (builder.Install (proj), "Install should have succeeded."); + + if (!Builder.UseDotNet) { + foreach (var abi in abis) { + Assert.IsTrue (builder.LastBuildOutput.ContainsText (Path.Combine ($"interpreter-{abi}", "libmono-native.so")), $"interpreter-{abi}/libmono-native.so should be used."); + Assert.IsTrue (builder.LastBuildOutput.ContainsText (Path.Combine ($"interpreter-{abi}", "libmonosgen-2.0.so")), $"interpreter-{abi}/libmonosgen-2.0.so should be used."); + } + } + + ClearAdbLogcat (); + RunAdbCommand ("shell setprop debug.mono.log all"); + if (CommercialBuildAvailable) + Assert.True (builder.RunTarget (proj, "_Run"), "Project should have run."); + else + AdbStartActivity ($"{proj.PackageName}/{proj.JavaPackageName}.MainActivity"); + + var logcatFilePath = Path.Combine (Root, builder.ProjectDirectory, "logcat.log"); + var didStart = WaitForActivityToStart (proj.PackageName, "MainActivity", logcatFilePath, 30); + RunAdbCommand ("shell setprop debug.mono.log \"\""); + Assert.True (didStart, "Activity should have started."); + Assert.IsTrue (File.ReadAllText (logcatFilePath).Contains ("Enabling Mono Interpreter"), "logcat output did not contain 'Enabling Mono Interpreter'."); + } + } }