Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Documentation/guides/messages/xa0116.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Compiler Error XA0116

Xamarin.Android's build process extracts various `EmbeddedResource`
files from its assemblies during a build. These include internal Java
source files that are required for a Xamarin.Android application to
start successfully. A `XA0116` error would only be encountered if one
of these required files is missing.

Consider submitting a [bug][bug] if you are getting this error under
normal circumstances.

[bug]: https://github.com/xamarin/xamarin-android/wiki/Submitting-Bugs,-Feature-Requests,-and-Pull-Requests
6 changes: 5 additions & 1 deletion src/Xamarin.Android.Build.Tasks/Tasks/CopyResource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public bool Run (Assembly assm, string ResourceName, string OutputPath, TaskLogg

// Copy out one of our embedded resources to a path
using (var from = GetManifestResourceStream (ResourceName)) {

if (from == null) {
Log.LogCodedError ("XA0116", $"Unable to find `EmbeddedResource` of name `{ResourceName}`.");
return false;
}

// If the resource already exists, only overwrite if it's changed
if (File.Exists (OutputPath)) {
var hash1 = MonoAndroidHelper.HashFile (OutputPath);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using Microsoft.Build.Framework;
using NUnit.Framework;
using System.Collections.Generic;
using System.IO;
using Xamarin.Android.Tasks;

namespace Xamarin.Android.Build.Tests
{
[TestFixture]
public class CopyResourceTests
{
string tempFile;
List<BuildErrorEventArgs> errors;
List<BuildMessageEventArgs> messages;
MockBuildEngine engine;

[SetUp]
public void Setup ()
{
tempFile = Path.GetTempFileName ();
engine = new MockBuildEngine (TestContext.Out,
errors: errors = new List<BuildErrorEventArgs> (),
messages: messages = new List<BuildMessageEventArgs> ());
}

[TearDown]
public void TearDown ()
{
File.Delete (tempFile);
}

// If we remove one of these, this test should fail
static object [] EmbeddedResources = new object [] {
new object[] { "machine.config" },
new object[] { "MonoRuntimeProvider.Bundled.java" },
new object[] { "NotifyTimeZoneChanges.java" },
new object[] { "Seppuku.java" },
new object[] { "IncrementalClassLoader.java" },
new object[] { "MultiDexLoader.java" },
new object[] { "Placeholder.java" },
};

[Test]
[TestCaseSource ("EmbeddedResources")]
public void FilesThatAreExpected (string resourceName)
{
var task = new CopyResource {
BuildEngine = engine,
ResourceName = resourceName,
OutputPath = tempFile,
};
Assert.IsTrue (task.Execute (), "task should succeed!");
FileAssert.Exists (tempFile);
Assert.AreNotEqual (0, new FileInfo (tempFile).Length, "file should be non-empty!");
}

[Test]
public void FileThatDoesNotExist ()
{
var resourceName = "thisdoesnotexist";
var task = new CopyResource {
BuildEngine = engine,
ResourceName = resourceName,
OutputPath = tempFile,
};
Assert.IsFalse (task.Execute (), "task should fail!");
Assert.AreEqual (1, errors.Count);
var error = errors [0];
Assert.AreEqual ("XA0116", error.Code);
StringAssert.Contains (resourceName, error.Message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<Compile Include="ResolveSdksTaskTests.cs" />
<Compile Include="AndroidResourceTests.cs" />
<Compile Include="ManagedResourceParserTests.cs" />
<Compile Include="Tasks\CopyResourceTests.cs" />
<Compile Include="Tasks\KeyToolTests.cs" />
<Compile Include="Aapt2Tests.cs" />
<Compile Include="Tasks\ValidateJavaVersionTests.cs" />
Expand Down