Skip to content
Draft
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/Xamarin.Android.Build.Tasks/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -974,6 +974,12 @@ To use a custom JDK path for a command line build, set the 'JavaSdkDirectory' MS
{0} - Maven artifact id
{1} - The HttpClient reported download exception message
</comment>
</data>
<data name="XA4238" xml:space="preserve">
<value>Could not load Java callable wrapper XML file '{0}': {1}</value>
<comment>The following are literal names and should not be translated: Java callable wrapper, XML.
{0} - Path to XML file
{1} - Exception message</comment>
</data>
<data name="XA4239" xml:space="preserve">
<value>Unknown Maven repository: '{0}'.</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,13 @@ void GenerateWrappers (List<ITaskItem> assemblies)
return;
}

var xml = JavaObjectsXmlFile.Import (wrappersPath, JavaObjectsXmlFileReadType.JavaCallableWrappers);
JavaObjectsXmlFile xml;
try {
xml = JavaObjectsXmlFile.Import (wrappersPath, JavaObjectsXmlFileReadType.JavaCallableWrappers);
} catch (InvalidOperationException ex) {
Log.LogCodedError ("XA4238", Properties.Resources.XA4238, wrappersPath, ex.Message);
return;
}

if (xml.JavaCallableWrappers.Count == 0) {
Log.LogDebugMessage ($"'{wrappersPath}' is empty, skipping.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,5 +119,30 @@ public void XA0119Interpreter ()
Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, "XA0119"), "Output should contain XA0119 warnings");
}
}

[Test]
public void XA4238 ()
{
var proj = new XamarinAndroidApplicationProject ();
proj.Sources.Add (new BuildItem ("Compile", "CustomView.cs") { TextContent = () => @"
using Android.Content;
using Android.Runtime;
using Android.Views;

namespace UnnamedProject
{
// Register attribute without package prefix should cause XA4238
[Register(""CustomView"")]
public class CustomView : View
{
public CustomView (Context context) : base (context) { }
}
}" });
using (var builder = CreateApkBuilder ()) {
builder.ThrowOnBuildFailure = false;
Assert.IsFalse (builder.Build (proj), "Build should have failed.");
Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, "XA4238"), "Output should contain XA4238 error");
}
}
}
}