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
4 changes: 4 additions & 0 deletions Documentation/guides/messages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,10 @@ Exceptions that have not been gracefully handled yet. Ideally these will be fix
These take the form of `XACCC7NNN`, where `CCC` is a 3 character code denoting the MSBuild Task that is throwing the exception,
and `NNN` is a 3 digit number indicating the type of the unhandled `Exception`.

## XA8xxx: Linker Step Errors

+ [XA8000/IL8000](xa8000.md): Could not find Android Resource '@anim/enterfromright'. Please update @(AndroidResource) to add the missing resource.

**Tasks:**
* `A2C` - `Aapt2Compile`
* `A2L` - `Aapt2Link`
Expand Down
21 changes: 21 additions & 0 deletions Documentation/guides/messages/xa8000.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
title: Xamarin.Android warning XA8000/IL8000
description: XA8000/IL8000 error code
ms.date: 06/01/2023
---
# Xamarin.Android error XA8000/IL8000

## Issue

```
Could not find Android Resource '@anim/enterfromright'. Please update @(AndroidResource) to add the missing resource.
```

## Solution

When trying to upgrade older nuget package references to use the
more recent Resource Designer Assembly, the system might encounter
fields which cannot be upgraded because the resource is missing
from either the dependency or the app.

To fix this issue the missing `AndroidResource` needs to be added to the application. Or the Nuget should be upgraded to use .net 8 or later.
1 change: 0 additions & 1 deletion build-tools/scripts/UpdateApkSizeReference.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/bash
./build-tools/scripts/nunit3-console bin/TestRelease/net472/Xamarin.Android.Build.Tests.dll --test=Xamarin.Android.Build.Tests.BuildTest2.BuildReleaseArm64
./dotnet-local.sh test bin/TestRelease/net7.0/Xamarin.Android.Build.Tests.dll --filter=Name~BuildReleaseArm64
cp bin/TestRelease/BuildReleaseArm64*.apkdesc src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/

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

6 changes: 6 additions & 0 deletions src/Microsoft.Android.Sdk.ILLink/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,10 @@
<comment>The following are literal names and should not be translated: AppDomain.CreateDomain(), AppDomain
{0} - The name of the assembly</comment>
</data>
<data name="XA8000" xml:space="preserve">
<value>Could not find Android Resource '{0}'. Please update @(AndroidResource) to add the missing resource.</value>
<comment>
{0} - An Android Resource Identifier.
</comment>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;

using Mono.Cecil;
Expand All @@ -13,6 +14,9 @@
using Mono.Tuner;
#if ILLINK
using Microsoft.Android.Sdk.ILLink;
using Resources = Microsoft.Android.Sdk.ILLink.Properties.Resources;
#else // !ILLINK
using Resources = Xamarin.Android.Tasks.Properties.Resources;
#endif // ILLINK

namespace MonoDroid.Tuner
Expand Down Expand Up @@ -120,6 +124,17 @@ Dictionary<string, MethodDefinition> BuildResourceDesignerPropertyLookup (TypeDe
return output;
}

string GetNativeTypeNameFromManagedTypeName (string name)
{
switch (name) {
case "Animation": return "anim";
case "Attribute": return "attr";
case "Boolean": return "bool";
case "Dimension": return "dimen";
default: return name.ToLower ();
}
}

protected override void FixBody (MethodBody body, TypeDefinition designer)
{
// replace
Expand All @@ -144,6 +159,14 @@ protected override void FixBody (MethodBody body, TypeDefinition designer)
instructions.Add (i, newIn);
} else {
LogMessage ($"DEBUG! Failed to find {key}!");
// The 'key' in this case will be something like Layout::Toolbar.
// We want format this into @layout/Toolbar so its easier to understand
// for the user.
var index = key.IndexOf ("::");
var typeName = GetNativeTypeNameFromManagedTypeName (key.Substring (0, index));
var identifier = key.Substring (index + 2);
var msg = string.Format (CultureInfo.CurrentCulture, Resources.XA8000, $"@{typeName}/{identifier}");
LogError (8000, msg);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ public virtual void LogMessage (string message)
Context.LogMessage (message);
}

public virtual void LogError (int code, string error)
{
#if ILLINK
Context.LogMessage (MessageContainer.CreateCustomErrorMessage (error, code, origin: new MessageOrigin ()));
#else // !ILLINK
Console.Error.WriteLine ($"error XA{code}: {error}");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ILLINK is not defined, we should be within Xamarin.Android.Build.Tasks.dll, right? In which case we should have a "real" MSBuild Task that can raise "real" MSBuild error messages, instead of going through Console.Error.WriteLine()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done in https://github.com/xamarin/xamarin-android/pull/8066/files#diff-6bfa8cb4f52234d33d427a9aa52682179ea4e86d986fa7b2c6c26504ffcd6d96R145 by overriding this method. The Console.Error.WriteLine here is just a backup.

#endif // !ILLINK
}

public virtual AssemblyDefinition Resolve (AssemblyNameReference name)
{
return Context.Resolve (name);
Expand Down

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 @@ -933,4 +933,10 @@ To use a custom JDK path for a command line build, set the 'JavaSdkDirectory' MS
{1} - A Filename.
</comment>
</data>
<data name="XA8000" xml:space="preserve">
<value>Could not find Android Resource '{0}'. Please update @(AndroidResource) to add the missing resource.</value>
<comment>
{0} - An Android Resource Identifier.
</comment>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ public override void LogMessage (string message)
logger.LogDebugMessage ("{0}", message);
}

public override void LogError (int code, string message)
{
logger.LogCodedError ($"XA{code}", message);
}

public override AssemblyDefinition Resolve (AssemblyNameReference name)
{
return resolver.Resolve (name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,14 @@ public static class KnownPackages
Id = "Mono.AotProfiler.Android",
Version = "7.0.0-preview1",
};
public static Package SkiaSharp = new Package () {
Id = "SkiaSharp",
Version = "2.88.3",
};
public static Package SkiaSharp_Views = new Package () {
Id = "SkiaSharp.Views",
Version = "2.88.3",
};
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,58 +8,58 @@
"Size": 1024
},
"assemblies/Java.Interop.dll": {
"Size": 58913
"Size": 58703
},
"assemblies/Mono.Android.dll": {
"Size": 87163
"Size": 86588
},
"assemblies/Mono.Android.Runtime.dll": {
"Size": 5895
"Size": 5798
},
"assemblies/rc.bin": {
"Size": 1182
"Size": 1235
},
"assemblies/System.Console.dll": {
"Size": 6438
"Size": 6442
},
"assemblies/System.Linq.dll": {
"Size": 9122
"Size": 9123
},
"assemblies/System.Private.CoreLib.dll": {
"Size": 516811
"Size": 536436
},
"assemblies/System.Runtime.dll": {
"Size": 2620
"Size": 2623
},
"assemblies/System.Runtime.InteropServices.dll": {
"Size": 3753
"Size": 3752
},
"assemblies/UnnamedProject.dll": {
"Size": 3219
"Size": 3349
},
"classes.dex": {
"Size": 19020
"Size": 19748
},
"lib/arm64-v8a/libmono-component-marshal-ilgen.so": {
"Size": 93552
},
"lib/arm64-v8a/libmonodroid.so": {
"Size": 379320
"Size": 380832
},
"lib/arm64-v8a/libmonosgen-2.0.so": {
"Size": 3090760
"Size": 3160360
},
"lib/arm64-v8a/libSystem.IO.Compression.Native.so": {
"Size": 723840
"Size": 723560
},
"lib/arm64-v8a/libSystem.Native.so": {
"Size": 94328
"Size": 94392
},
"lib/arm64-v8a/libSystem.Security.Cryptography.Native.Android.so": {
"Size": 155056
"Size": 154904
},
"lib/arm64-v8a/libxamarin-app.so": {
"Size": 16720
"Size": 16624
},
"META-INF/BNDLTOOL.RSA": {
"Size": 1213
Expand Down Expand Up @@ -95,5 +95,5 @@
"Size": 1904
}
},
"PackageSize": 2632010
"PackageSize": 2685258
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not related to this PR, but why'd the package size increase so much?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like its

"assemblies/System.Private.CoreLib.dll": {
      "Size": 516811
      "Size": 536436
    },

or at least a fair chunk of it will be

}
Loading