Skip to content

Trying to bind an AppCompatActivity derived Activity results in errors #9049

@MihaMarkic

Description

@MihaMarkic

Android framework version

net8.0-android

Affected platform version

VS 2022 17.10.3 SDK 8.0.302

Description

I have this Kotlin guy in android studio module:

class TestActivity: AppCompatActivity() {
}

which I'm trying to bind. I've created the .aar, .net android library project, added a ton of packages and when compiling, I get these errors:

Reference to type 'IHasDefaultViewModelProviderFactory' claims it is defined in 'Xamarin.AndroidX.Lifecycle.ViewModel', but it could not be found
 error CS7069: Reference to type 'IViewModelStoreOwner' claims it is defined in 'Xamarin.AndroidX.Lifecycle.ViewModel', but it could not be found
error CS7069: Reference to type 'ILifecycleOwner' claims it is defined in 'Xamarin.AndroidX.Lifecycle.Common', but it could not be found

in line

_members.InstanceMethods.FinishCreateInstance (__id, this, null);

of generated constructor.

I have these NuGet libraries configured in .csproj

<PackageReference Include="Xamarin.AndroidX.Lifecycle.Common" Version="2.8.2" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData.Core" Version="2.8.2" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.LiveData.Core.Ktx" Version="2.8.2" />
<PackageReference Include="Xamarin.AndroidX.Lifecycle.ViewModel" Version="2.8.2" />
<PackageReference Include="Xamarin.Kotlin.StdLib" Version="2.0.0" />
<PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.7.0" />
<PackageReference Include="Xamarin.AndroidX.Camera.Camera2" Version="1.3.3.3" />
<PackageReference Include="Xamarin.AndroidX.Camera.Lifecycle" Version="1.3.3.3" />
<PackageReference Include="Xamarin.AndroidX.Camera.View" Version="1.3.3.3" />
<PackageReference Include="Xamarin.AndroidX.ConstraintLayout" Version="2.1.4.13" />
<PackageReference Include="Xamarin.Google.MLKit.BarcodeScanning" Version="117.2.0.6" />
<PackageReference Include="Xamarin.GooglePlayServices.Tasks" Version="118.1.0.2" />

Basically it's a vanilla AppCompatActivity subtype I wish to bind.

Steps to Reproduce

Will post a sample project if required

Did you find any workaround?

No

Relevant log output

Reference to type 'IHasDefaultViewModelProviderFactory' claims it is defined in 'Xamarin.AndroidX.Lifecycle.ViewModel', but it could not be found
 error CS7069: Reference to type 'IViewModelStoreOwner' claims it is defined in 'Xamarin.AndroidX.Lifecycle.ViewModel', but it could not be found
error CS7069: Reference to type 'ILifecycleOwner' claims it is defined in 'Xamarin.AndroidX.Lifecycle.Common', but it could not be found

Metadata

Metadata

Assignees

Labels

Area: App+Library BuildIssues when building Library projects or Application projects.Area: BindingsIssues in Java Library Binding projects.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions