AndroidX icon indicating copy to clipboard operation
AndroidX copied to clipboard

Use `<AndroidLibrary>` rather than `.targets` files.

Open jpobst opened this issue 1 year ago • 1 comments

Previously, our template would create bindings using <InputJar>, then manually add the jar/aar and any Proguard files to the .nupgk, and then use a .targets file to add these payloads to the Android application.

This was likely done for 2 reasons:

  • Better build performance by not needing to extract an embedded .jar/.aar.
  • Poor initial support for the other files contained in .aar files. (Proguard, etc.)

In .NET times, both of these issues have been resolved, and we can replace our custom hacks with the built-in <AndroidLibrary> build item, reducing the maintenance burden of custom solutions.


Note there is an issue with resources if the name of the included .aar is different from what our previous package versions named it:

error APT2260: resource style/TextAppearance.Compat.Notification.Info (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification.Info) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2260: resource style/TextAppearance.Compat.Notification.Info (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification.Info) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2260: resource style/TextAppearance.Compat.Notification.Info (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification.Info) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2260: resource style/TextAppearance.Compat.Notification (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2260: resource style/TextAppearance.Compat.Notification (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2260: resource style/TextAppearance.Compat.Notification (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2260: resource style/TextAppearance.Compat.Notification.Time (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification.Time) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2260: resource style/TextAppearance.Compat.Notification.Time (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification.Time) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2260: resource style/TextAppearance.Compat.Notification.Time (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification.Time) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2260: resource style/TextAppearance.Compat.Notification.Title (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification.Title) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2260: resource style/TextAppearance.Compat.Notification.Title (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification.Title) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2260: resource style/TextAppearance.Compat.Notification.Title (aka com.companyname.BuildAllDotNet:style/TextAppearance.Compat.Notification.Title) not found. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]
error APT2062: failed linking references. [/Users/runner/work/1/s/samples/dotnet/BuildAllDotNet/BuildAllDotNet.csproj]

I was unable to find the root cause of this, so I added a workaround to rename the Java library the same as we previously used. (@(art.MavenGroupId).@(art.MavenArtifactId).[jar|aar])

jpobst avatar May 14 '24 23:05 jpobst

Original package example:

image

New package example:

image

A future PR will try to remove the .targets file completely by moving the remaining line to a common base package.

jpobst avatar May 17 '24 21:05 jpobst