Home > Back-end >  Error: Failed linking file resources. Xamarin Android
Error: Failed linking file resources. Xamarin Android

Time:06-28

After Migrate my Xamarin Android app with AndroidX. This error is coming.

Error: failed linking file resources. ZZAPP.Android
Error: attribute drawableStartCompat not found.

Error: attribute drawableLeftCompat not found.

This is my 1st layout file:

<?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">

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="horizontal">

<NumberPicker
        android:id="@ id/picker_year"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="20dp"
        android:layout_marginRight="20dp" >
</NumberPicker>
        
<NumberPicker
        android:id="@ id/picker_month"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginEnd="20dp"
        android:layout_marginRight="20dp">
</NumberPicker>

<NumberPicker
        android:id="@ id/picker_day"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
</NumberPicker>
 </LinearLayout>
</LinearLayout>

This is my 2nd layout file:

<?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">

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="horizontal">

<NumberPicker
        android:id="@ id/number_picker"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
</NumberPicker>
</LinearLayout>
</LinearLayout>


    

Any help is appreciated. Thanks!

CodePudding user response:

At first, please add the xmlns:app="http://schemas.android.com/apk/res-auto" in to the xml, such as:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"

And then you can try again, if still not working, you can try to update the version of the material package.

Update

I had test on my ptoject:

  1. Xamarin.AndroidX.AppCompat.AppCompatResources 1.3.1.1
  2. Xamarin.Forms 5.0.0.2291
  3. Xamarin.Google.Android.Material 1.4.0.2
  4. Visual Studio 2022 17.3.0 proview 2.0
  • Related