'Error CS0246 The type or namespace name 'Androidx' could not be found (are you missing a using directive or an assembly reference?)
I am migrating Xamarin.Android application from Andorid 9 to Android 10. I have updated all the support packages to Andoridx packages.
In .axml files after changing the android.support.v7.widget.RecyclerView to androidx.recyclerview.widget.RecyclerView , I am getting "Error CS0246 The type or namespace name 'Androidx' could not be found (are you missing a using directive or an assembly reference?)" in the respective .axml.g.cs file.
Attached screenshot of .axml.g.cs file
I have tried deleting obj, bin folders. Clean, rebuilt the application. Still not resolved. Could anyone help me resolving this issue? Thanks in Advance
activity1.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/backgroundColor">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<include
android:id="@+id/Indicator"
layout="@layout/Indicator" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
android:paddingBottom="@dimen/margin_small"
/>
</FrameLayout>
</LinearLayout>
Solution 1:[1]
At first, the namespace is AndroidX.RecyclerView.Widget;
not Androidx.
So you can try to add the following code in the .cs file.
using AndroidX.RecyclerView.Widget;
or
private AndroidX.RecyclerView.Widget.RecyclerView _recycler_view;
And then, if it still doesn't work. You can download the nuget package Xamarin.AndroidX.RecyclerView
from the package manager.
You should create the android layout file such as:
The cause is the nuget package in your project too old. You can try to use a new package to replace it.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |