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
34 changes: 34 additions & 0 deletions Documentation/guides/messages/xa0121.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: Xamarin.Android warning XA0121
description: XA0121 warning code
ms.date: 09/19/2019
---
# Xamarin.Android warning XA0121

## Issue

The behavior implemented in the
`<GetAdditionalResourcesFromAssemblies/>` MSBuild task is now
deprecated.

This MSBuild task is a precursor to [Xamarin.Build.Download][xbd] that
enables downloading of Android packages from the internet.

Libraries using any of the following custom assembly-level attributes
will encounter this warning:

* `IncludeAndroidResourcesFromAttribute`
* `NativeLibraryReferenceAttribute`
* `JavaLibraryReferenceAttribute`

## Solution

The [Xamarin Support Libraries][supportlibs], can be simply updated to
a newer version on NuGet.

Library authors will need to remove usage of these deprecated
attributes. Their functionality will be removed in a future version of
Xamarin.Android.

[xbd]: https://www.nuget.org/packages/Xamarin.Build.Download
[supportlibs]: https://github.com/xamarin/AndroidSupportComponents
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Android {

[AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)]
[Obsolete ("This attribute is deprecated and will be removed in a future release.")]
public class IncludeAndroidResourcesFromAttribute : ReferenceFilesAttribute
{
public IncludeAndroidResourcesFromAttribute (string path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Android {

[AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)]
[Obsolete ("This attribute is deprecated and will be removed in a future release.")]
sealed public class NativeLibraryReferenceAttribute : ReferenceFilesAttribute
{
public NativeLibraryReferenceAttribute (string filename)
Expand Down
2 changes: 1 addition & 1 deletion src/Mono.Android/Android/ReferenceFilesAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;

namespace Android {

[Obsolete ("This attribute is deprecated and will be removed in a future release.")]
public abstract class ReferenceFilesAttribute : Attribute
{
internal ReferenceFilesAttribute () {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Java.Interop {

[AttributeUsage (AttributeTargets.Assembly, AllowMultiple = true)]
[Obsolete ("This attribute is deprecated and will be removed in a future release.")]
public class JavaLibraryReferenceAttribute : Android.ReferenceFilesAttribute
{
public JavaLibraryReferenceAttribute (string filename)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ internal static string ErrorMessage (CustomAttributeValue<object> attributeValue
void AddAttributeValue (ICollection<string> items, CustomAttributeValue<object> attributeValue, string errorCode, string errorFmt,
bool isDirectory, string fullPath, string attributeFullName)
{
LogCodedWarning ("XA0121",
$"Assembly '{Path.GetFileName (fullPath)}' is using a deprecated attribute '[assembly: {attributeFullName}]'. Use a newer version of this NuGet package or notify the library author.");

if (attributeValue.NamedArguments.Length == 0 || attributeValue.FixedArguments.Length != 1) {
LogCodedWarning (errorCode, "Attribute {0} doesn't have expected one constructor agrument", attributeFullName);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2296,6 +2296,7 @@ public void ResourceExtraction ([Values (true, false)] bool useAapt2)
using (var builder = CreateApkBuilder (Path.Combine ("temp", TestName))) {
Assert.IsTrue (builder.DesignTimeBuild (proj), "design-time build should have succeeded");
Assert.IsTrue (builder.Build (proj), "build should have succeeded");
Assert.IsTrue (StringAssertEx.ContainsText (builder.LastBuildOutput, "XA0121"), "Output should contain XA0121 warnings");
var targetAar = Path.Combine (CachePath, "Xamarin.Android.Support.v7.AppCompat", "23.1.1.0",
"content", "m2repository", "com", "android", "support", "appcompat-v7", "23.1.1", "appcompat-v7-23.1.1.aar");
if (File.Exists (targetAar)) {
Expand Down