Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate @(AndroidLibrary) item groups for .NET 6 #5357

Closed
jonathanpeppers opened this issue Dec 2, 2020 · 2 comments · Fixed by #5372
Closed

Consolidate @(AndroidLibrary) item groups for .NET 6 #5357

jonathanpeppers opened this issue Dec 2, 2020 · 2 comments · Fixed by #5372
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Milestone

Comments

@jonathanpeppers
Copy link
Member

As discussed a couple things can improve upon fcd7cf8:

  1. We should support @(AndroidLibrary) in "legacy" Xamarin.Android and document it. It seems like a convenience that would not be to difficult to support.
  2. We should "hide" the old item groups in .NET 6 (via @(AvailableItemName)) so they don't appear in the dropdown in IDEs.
  3. @(AndroidNativeLibrary) should remain distinct from @(AndroidLibrary) as the %(Bind) and %(Abi) metadata do not really make sense for both types of libraries.
@jonathanpeppers jonathanpeppers added the Area: App+Library Build Issues when building Library projects or Application projects. label Dec 2, 2020
@jonathanpeppers jonathanpeppers added this to the One .NET milestone Dec 2, 2020
@jonathanpeppers jonathanpeppers self-assigned this Dec 2, 2020
@jonpryor
Copy link
Member

jonpryor commented Dec 2, 2020

"Related" from our discussions earlier today: we need to overhaul the XA4301 error message emitted, currently:

Native library '{0}' will not be bundled because it has an unsupported ABI.

This message is not actionable, and thus in the proposed workflow:

  1. User adds libexample.so file to the directory containing Foo.csproj
  2. User builds Foo.csproj
  3. Build quickly fails with XA4301, as we can't infer the ABI for libexample.so.

We thus need to update XA4301 with an appropriate fix, to either

  1. Edit Foo.csproj to add libexample.so to an @(AndroidNativeLibrary) item group, and set %(Abi), or
  2. Move libexample.so into an e.g. libs/ABI directory.

@jonathanpeppers
Copy link
Member Author

I filed a different issue for the error message: #5358

jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Dec 4, 2020
Fixes: dotnet#5357

The new `@(AndroidLibrary)` item group can now be used in "legacy"
Xamarin.Android:

    <AndroidLibrary Include="foo.jar" />
    <AndroidLibrary Include="bar.aar" />

* Application and class library projects:
  * `foo.jar` maps to `AndroidJavaLibrary`
  * `bar.aar` maps to `AndroidAarLibrary`
* Java binding projects:
  * `foo.jar` maps to `EmbeddedJar`
  * `foo.jar` maps to `EmbeddedReferenceJar` if `Bind="false"` metadata is added
  * `bar.aar` maps to `LibraryProjectZip`
* Additionally:
  * `@(AndroidNativeLibrary)` now will be used for native libraries.
    You can use `@(AndroidNativeLibrary)` instead of
    `@(EmbeddedNativeLibrary)`.

All `@(AvailableItemItems)` are now defined in a single
`Xamarin.Android.AndroidItems.targets` that is imported by all project
types: both legacy apps, libraries, and bindings and .NET 6.

TODO: more documentation changes

I updated a few binding tests to use `@(AndroidLibrary)`. There are
still several more tests using the old item names.
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Dec 4, 2020
Fixes: dotnet#5357

The new `@(AndroidLibrary)` item group can now be used in "legacy"
Xamarin.Android:

    <AndroidLibrary Include="foo.jar" />
    <AndroidLibrary Include="bar.aar" />

* Application and class library projects:
  * `foo.jar` maps to `AndroidJavaLibrary`
  * `bar.aar` maps to `AndroidAarLibrary`
* Java binding projects:
  * `foo.jar` maps to `EmbeddedJar`
  * `foo.jar` maps to `EmbeddedReferenceJar` if `Bind="false"` metadata is added
  * `bar.aar` maps to `LibraryProjectZip`
* Additionally:
  * `@(AndroidNativeLibrary)` now will be used for native libraries.
    You can use `@(AndroidNativeLibrary)` instead of
    `@(EmbeddedNativeLibrary)`.

All `@(AvailableItemNames)` are now defined in a single
`Xamarin.Android.AndroidItems.targets` that is imported by all project
types: both legacy apps, libraries, and bindings and .NET 6.

I documented the changes to the item groups, some of which didn't have
documentation at all.

I updated a few binding tests to use `@(AndroidLibrary)`. There are
still several more tests using the old item names.
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Dec 4, 2020
Fixes: dotnet#5357

The new `@(AndroidLibrary)` item group can now be used in "legacy"
Xamarin.Android:

    <AndroidLibrary Include="foo.jar" />
    <AndroidLibrary Include="bar.aar" />

* Application and class library projects:
  * `foo.jar` maps to `AndroidJavaLibrary`
  * `bar.aar` maps to `AndroidAarLibrary`
* Java binding projects:
  * `foo.jar` maps to `EmbeddedJar`
  * `foo.jar` maps to `EmbeddedReferenceJar` if `Bind="false"` metadata is added
  * `bar.aar` maps to `LibraryProjectZip`
* Additionally:
  * `@(AndroidNativeLibrary)` now will be used for native libraries.
    You can use `@(AndroidNativeLibrary)` instead of
    `@(EmbeddedNativeLibrary)`.

All `@(AvailableItemNames)` are now defined in a single
`Xamarin.Android.AndroidItems.targets` that is imported by all project
types: both legacy apps, libraries, and bindings and .NET 6.

I documented the changes to the item groups, some of which didn't have
documentation at all.

I updated a few binding tests to use `@(AndroidLibrary)`. There are
still several more tests using the old item names.
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Dec 8, 2020
Fixes: dotnet#5357

The new `@(AndroidLibrary)` item group can now be used in "legacy"
Xamarin.Android:

    <AndroidLibrary Include="foo.jar" />
    <AndroidLibrary Include="bar.aar" />

* Application and class library projects:
  * `foo.jar` maps to `AndroidJavaLibrary`
  * `bar.aar` maps to `AndroidAarLibrary`
* Java binding projects:
  * `foo.jar` maps to `EmbeddedJar`
  * `foo.jar` maps to `EmbeddedReferenceJar` if `Bind="false"` metadata is added
  * `bar.aar` maps to `LibraryProjectZip`
* Additionally:
  * `@(AndroidNativeLibrary)` now will be used for native libraries.
    You can use `@(AndroidNativeLibrary)` instead of
    `@(EmbeddedNativeLibrary)`.

All `@(AvailableItemNames)` are now defined in a single
`Xamarin.Android.AndroidItems.targets` that is imported by all project
types: both legacy apps, libraries, and bindings and .NET 6.

I documented the changes to the item groups, some of which didn't have
documentation at all.

I updated a few binding tests to use `@(AndroidLibrary)`. There are
still several more tests using the old item names.
jonathanpeppers added a commit to jonathanpeppers/xamarin-android that referenced this issue Dec 9, 2020
Fixes: dotnet#5357

The new `@(AndroidLibrary)` item group can now be used in "legacy"
Xamarin.Android:

    <AndroidLibrary Include="foo.jar" />
    <AndroidLibrary Include="bar.aar" />

* Application and class library projects:
  * `foo.jar` maps to `AndroidJavaLibrary`
  * `bar.aar` maps to `AndroidAarLibrary`
* Java binding projects:
  * `foo.jar` maps to `EmbeddedJar`
  * `foo.jar` maps to `EmbeddedReferenceJar` if `Bind="false"` metadata is added
  * `bar.aar` maps to `LibraryProjectZip`
* Additionally:
  * `@(AndroidNativeLibrary)` now will be used for native libraries.
    You can use `@(AndroidNativeLibrary)` instead of
    `@(EmbeddedNativeLibrary)`.

All `@(AvailableItemNames)` are now defined in a single
`Xamarin.Android.AndroidItems.targets` that is imported by all project
types: both legacy apps, libraries, and bindings and .NET 6.

I documented the changes to the item groups, some of which didn't have
documentation at all.

I updated a few binding tests to use `@(AndroidLibrary)`. There are
still several more tests using the old item names.
jonpryor pushed a commit that referenced this issue Dec 9, 2020
…#5372)

Fixes: #5357

The new `@(AndroidLibrary)` item group (8cc3e4f) can now be used in
"legacy" Xamarin.Android:

	<AndroidLibrary Include="foo.jar" />
	<AndroidLibrary Include="bar.aar" />

  * Application and class library projects:
      * `foo.jar` maps to `@(AndroidJavaLibrary)`
      * `bar.aar` maps to `@(AndroidAarLibrary)`

  * Java binding projects:
      * `foo.jar` maps to `@(EmbeddedJar)` when
        `%(AndroidLibrary.Bind)="true"` (the default))
      * `foo.jar` maps to `@(EmbeddedReferenceJar)` if
        `%(AndroidLibrary.Bind)="false"` metadata is added
      * `bar.aar` maps to `@(LibraryProjectZip)`

  * Additionally:
      * `@(AndroidNativeLibrary)` now will be used for native
        libraries.  You can use `@(AndroidNativeLibrary)` instead of
        `@(EmbeddedNativeLibrary)`.

All `@(AvailableItemNames)` are now defined in a single
`Xamarin.Android.AndroidItems.targets` that is imported by all
project types: legacy apps, legacy libraries, legacy bindings,
and .NET 6 projects.

I documented the changes to the item groups, some of which didn't
have documentation at all.

I updated a few binding tests to use `@(AndroidLibrary)`.  There are
still several more tests using the old item names.
@ghost ghost locked as resolved and limited conversation to collaborators Jun 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects.
Projects
None yet
2 participants