Coder Social home page Coder Social logo

Comments (4)

jpobst avatar jpobst commented on June 20, 2024 1

I suspect using <Reference> is the issue. These .dlls do not contain the .aar embedded in them for build performance reasons.

When you reference it as a <PackageReference> the MSBuild system will run any .targets files in the NuGet package when you build your project.

If you look in the NuGet you'll see build\monoandroid12.0\Xamarin.AndroidX.Fragment.targets.

This contains this MSBuild which adds the .aar to your project:

<ItemGroup>
  <AndroidAarLibrary Include="$(MSBuildThisFileDirectory)..\..\aar\androidx.fragment.fragment.aar">
    <AndroidXSkipAndroidXMigration>true</AndroidXSkipAndroidXMigration>
  </AndroidAarLibrary>
</ItemGroup>

By using a <Reference> instead of a <PackageReference> this never gets executed and the .aar never gets added to your application.

from androidx.

justin-caldicott avatar justin-caldicott commented on June 20, 2024 1

Many thanks @jpobst, all set!

I'm not in a position to switch to <PackageReference> just yet. But what you explained let me realise I could just add the android library references to the project file directly. They probably would have been added if I'd installed the package properly, rather than just installing them to a folder. Really do need to update our build scripts!

So I have a bunch of additional lines like:

    <AndroidAarLibrary Include="$(ProjectDir)..\packages\Xamarin.AndroidX.Fragment\aar\androidx.fragment.fragment.aar"/>

There were already a couple there for Kotlin.StdLib and Kotlin.StdLib.Common.

Sorry, not really an issue in the product then, just support.. but much appreciated. Closing.

from androidx.

jpobst avatar jpobst commented on June 20, 2024

Have you added the following NuGet packages to your project?

  • Xamarin.AndroidX.Fragment
  • Xamarin.AndroidX.Core

from androidx.

justin-caldicott avatar justin-caldicott commented on June 20, 2024

Thanks @jpobst, yes I added the new packages and followed the errors in Rider to make sure all implicit dependencies are included too. There are no C# errors now, just these java ones.

I admit I'm not sure how the java side of the bindings work. The java files with errors are in e.g. obj/Debug/android/<guid>/SomeFragment.java. The lines it's complaining about are:

public class SomeFragment
	extends androidx.fragment.app.Fragment <<<<<< javac cannot find androidx.fragment.app
	implements
		mono.android.IGCUserPeer

I saw in the installed packages there's an aar folder with e.g. androidx.fragment.fragment.aar inside. Presumably this is where it should be finding the package from?

One unusual thing here is we restore packages with -ExcludeVersion to a packages folder within the repo root. Assembly resolution is OK with this due to hint paths, e.g.

    <Reference Include="Xamarin.AndroidX.Fragment">
      <HintPath>..\packages\Xamarin.AndroidX.Fragment\lib\monoandroid12.0\Xamarin.AndroidX.Fragment.dll</HintPath>
    </Reference>

Maybe this causes problems for java package resolution somehow? It didn't have this behaviour on previous versions, but then we're jumping a lot of versions in one go as the app wasn't updated for a couple of years.

from androidx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.