Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to use Android Support Library v4

I'm trying to use the DrawerLayout from android.support.v4 library. I have added Xamarin.Android.Support.v4 package using Nuget but I'm still not able to compile the application and I face the following errors:

    Error   1    error: cannot find symbol
        android.support.v4.content.Loader.OnLoadCanceledListener
  symbol:   class OnLoadCanceledListener
  location: class Loader
    xxx\obj\Debug\android\src\mono\android\support\v4\content\Loader_OnLoadCanceledListenerImplementor.java 8   36  xxx
Error   6    error: cannot find symbol
        android.support.v4.view.MenuItemCompat.OnActionExpandListener
  symbol:   class OnActionExpandListener
  location: class MenuItemCompat
    xxx\obj\Debug\android\src\mono\android\support\v4\view\MenuItemCompat_OnActionExpandListenerImplementor.java    8   41  xxx
Error   7    error: cannot find symbol
        android.support.v4.view.OnApplyWindowInsetsListener
  symbol:   class OnApplyWindowInsetsListener
  location: package android.support.v4.view
    xxx\obj\Debug\android\src\mono\android\support\v4\view\OnApplyWindowInsetsListenerImplementor.java  8   26  xxx
Error   12   error: cannot find symbol
        android.support.v4.view.ViewPropertyAnimatorListener
  symbol:   class ViewPropertyAnimatorListener
  location: package android.support.v4.view
    xxx\obj\Debug\android\src\mono\android\support\v4\view\ViewPropertyAnimatorListenerImplementor.java 8   26  xxx
Error   13   error: cannot find symbol
        android.support.v4.view.ViewPropertyAnimatorUpdateListener
  symbol:   class ViewPropertyAnimatorUpdateListener
  location: package android.support.v4.view
    xxx\obj\Debug\android\src\mono\android\support\v4\view\ViewPropertyAnimatorUpdateListenerImplementor.java   8   26  xxx
Error   10   error: cannot find symbol
    private native android.support.v4.view.WindowInsetsCompat n_onApplyWindowInsets (android.view.View p0, android.support.v4.view.WindowInsetsCompat p1);
  symbol:   class WindowInsetsCompat
  location: package android.support.v4.view
    xxx\obj\Debug\android\src\mono\android\support\v4\view\OnApplyWindowInsetsListenerImplementor.java  32  128 xxx
Error   11   error: cannot find symbol
    private native android.support.v4.view.WindowInsetsCompat n_onApplyWindowInsets (android.view.View p0, android.support.v4.view.WindowInsetsCompat p1);
  symbol:   class WindowInsetsCompat
  location: package android.support.v4.view
    xxx\obj\Debug\android\src\mono\android\support\v4\view\OnApplyWindowInsetsListenerImplementor.java  32  40  xxx
Error   8    error: cannot find symbol
    public android.support.v4.view.WindowInsetsCompat onApplyWindowInsets (android.view.View p0, android.support.v4.view.WindowInsetsCompat p1)
  symbol:   class WindowInsetsCompat
  location: package android.support.v4.view
    xxx\obj\Debug\android\src\mono\android\support\v4\view\OnApplyWindowInsetsListenerImplementor.java  27  118 xxx
Error   9    error: cannot find symbol
    public android.support.v4.view.WindowInsetsCompat onApplyWindowInsets (android.view.View p0, android.support.v4.view.WindowInsetsCompat p1)
  symbol:   class WindowInsetsCompat
  location: package android.support.v4.view
    xxx\obj\Debug\android\src\mono\android\support\v4\view\OnApplyWindowInsetsListenerImplementor.java  27  32  xxx
Error   2    error: package android.support.v4.media.session.MediaSessionCompat does not exist
        android.support.v4.media.session.MediaSessionCompat.OnActiveChangeListener
    xxx\obj\Debug\android\src\mono\android\support\v4\media\session\MediaSessionCompat_OnActiveChangeListenerImplementor.java   8   54  xxx
Error   3    error: package android.support.v4.os.CancellationSignal does not exist
        android.support.v4.os.CancellationSignal.OnCancelListener
    xxx\obj\Debug\android\src\mono\android\support\v4\os\CancellationSignal_OnCancelListenerImplementor.java    8   43  xxx
Error   4    error: package android.support.v4.view.ActionProvider does not exist
        android.support.v4.view.ActionProvider.SubUiVisibilityListener
    xxx\obj\Debug\android\src\mono\android\support\v4\view\ActionProvider_SubUiVisibilityListenerImplementor.java   8   41  xxx
Error   5    error: package android.support.v4.view.ActionProvider does not exist
        android.support.v4.view.ActionProvider.VisibilityListener
    xxx\obj\Debug\android\src\mono\android\support\v4\view\ActionProvider_VisibilityListenerImplementor.java    8   41  xxx
Error   14   error: package android.support.v4.widget.SwipeRefreshLayout does not exist
        android.support.v4.widget.SwipeRefreshLayout.OnRefreshListener
    xxx\obj\Debug\android\src\mono\android\support\v4\widget\SwipeRefreshLayout_OnRefreshListenerImplementor.java   8   47  xxx

It seems to me that I should add a jar or something like that to the Xamarin project, Please tell me how and where could I do this if I'm right at this point. Thanks for any help

like image 719
a.toraby Avatar asked Dec 15 '22 11:12

a.toraby


2 Answers

For me this was caused by killing VS during the initial build of my first Xamarin project after a reinstall.

It looked as though the process had hung, but apparently it was downloading from google at a slow rate.

Quit Visual studio

Delete / rename c:\Users\username\AppData\Local\Xamarin

Open the solution again

Clean the solution

Compile, wait until it finishes completely.

On Windows, use Resource Monitor to determine if a download is in progress.

MSBuild will be downloading from something.1e100.net.

like image 199
Michael Ribbons Avatar answered Jan 12 '23 05:01

Michael Ribbons


It should just work by adding the NuGet package.

A couple of things to check.

  1. The full path to the files it cannot find if you are on a Windows file system cannot be more than 255 characters long
  2. Remove the NuGet package and try adding it again to see if that helps
  3. Make sure you have latest stable version of all the tools
  4. Make sure everything is ok in your Android SDK installation
like image 33
Cheesebaron Avatar answered Jan 12 '23 05:01

Cheesebaron