Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

NuGet error updating Xamarin.Android.Support.v7.AppCompat 21.0.0.0

PavelIvanovPavelIvanov RUMember ✭✭
edited December 2014 in Xamarin.Android

Hello! I've noticed that Xamarin updated android support libraries bindings in NuGet repo to 21.0.0.0 release version yesterday. Now I'm trying to update references in my Visual Studio Xamarin project to the last version.
https://www.nuget.org/packages/Xamarin.Android.Support.v7.AppCompat/
But while updating Package Manager Console tells me that something is wrond with my project.

`PM> Install-Package Xamarin.Android.Support.v7.AppCompat
Attempting to resolve dependency 'Xamarin.Android.Support.v4 (≥ 21.0.0.0)'.
Installing 'Xamarin.Android.Support.v7.AppCompat 21.0.0.0'.
Successfully installed 'Xamarin.Android.Support.v7.AppCompat 21.0.0.0'.
Adding 'Xamarin.Android.Support.v7.AppCompat 21.0.0.0' to ....
Uninstalling 'Xamarin.Android.Support.v7.AppCompat 21.0.0.0'.
Successfully uninstalled 'Xamarin.Android.Support.v7.AppCompat 21.0.0.0'.
Install failed. Rolling back...
Install-Package : Could not install package 'Xamarin.Android.Support.v7.AppCompat 21.0.0.0'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v2.2', but the package does not
contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
At line:1 char:1

  • Install-Package Xamarin.Android.Support.v7.AppCompat
  • ~~~~~~~~~~~~
    • CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
    • FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
      `
      Meawhile, actulally I has such properties:

image

Could anyone please help to unerstand what does that mean? And especially "You are trying to install this package into a project that targets 'MonoAndroid,Version=v2.2" string.

Posts

  • mattwardmattward GBMember Xamurai

    NuGet looks at your project's target framework and version to see if the NuGet packages are compatible. As far as NuGet is aware your project is targeting MonoAndroid version 2.2

    Looking at the screenshot that should map to what you have selected in Compile using Android version. However that does not seem to match since you have Android 5.0 installed.

    I would check your .csproj and see what is in that file. Then you can either change it manually or use the drop down to explicitly pick a target framework instead of using the latest to see if that fixes it.

  • @mattward‌ same problem here can you please guide me, How can i add v7 support library to my app, because i want implement material design in my app,

    this is my .csproj

    <?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <ProjectView>ShowAllFiles</ProjectView> <AndroidDesignerPreferredDevice>Nexus 4</AndroidDesignerPreferredDevice> </PropertyGroup> </Project>

  • hi @PavelIvanov did you resolve your problem can you please guide me

  • mattwardmattward GBMember Xamurai

    @Manikandan.5390 - What error are you seeing? What is the TargetFrameworkVersion in your project file (.csproj)?

    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
    
  • semicolosemicolo USMember ✭✭
    edited December 2014

    Same problem for me, in the packages.config file, all packages have targetFramework="MonoAndroid22", I'll try reinstalling all packages to see if it fixes the issue.
    I don't think the android target version is saved in the csproj, it doesn't change when I switch to another version.
    (just checked, the TargetFrameworkVersion is empty in my csproj)

  • semicolosemicolo USMember ✭✭

    Tried to set the TargetFrameworkVersion to v2.3, v4.0, not working, It installs when set to v5.0. Need to reinstall all other packages now I guess.

  • mattwardmattward GBMember Xamurai

    The TargetFrameworkVersion should be updated by Visual Studio if you change the selected API level to something other than Use Latest Platform in the Compile using Android Version from the project Properties. If that is not working can you file a bug on bugzilla with your Xamarin setup information?

  • semicolosemicolo USMember ✭✭

    I was playing with "Minimum Android to target" and "Target Android version", that's why I didn't see it changing.

    So is that a bug that the value is empty when "Use Latest Platform" is used in "Compile using Android version:"? Nuget seems to think the version is v2.2 by default.

  • mattwardmattward GBMember Xamurai

    The names are perhaps a bit confusing :)

    NuGet uses the TargetFrameworkVersion defined by the project when checking if a NuGet package is compatible. This is set by the Compile using Android version drop down and not the Target Android version.

    If there is no TargetFrameworkVersion defined in your project then the Xamarin Android MSBuild targets default to returning version 2.2

    At compile time the Xamarin Android MSBuild targets may well be using the latest platform available but from NuGet and Visual Studio's point of view the target framework version will be 2.2 if none is specified or whatever is in the project file.

    Xamarin Studio has different behaviour to Visual Studio since it will add the TargetFrameworkVersion to your project and use the latest version available on your machine. Not sure which IDE is using the better approach here :)

  • lufo88lufo88 USMember ✭✭✭

    Same problem here. My settings are:

    Compile using android version: "use latest platform (android 21)"

    Minimum Android to target: "Api level 14"

    Target Android version: "use compile version"

    In the csproj file there isn't a TargetFrameworkVersion tag. How can I resolve this issue?

  • mattwardmattward GBMember Xamurai

    If you are using Visual Studio then you may be running into a bug where the TargetFrameworkVersion is cleared if you are compiling using the latest platform.

    You could try adding the TargetFrameworkVersion element to your .csproj manually or change the Compile using android version setting so it targets a particular Android version temporarily.

  • PavelIvanovPavelIvanov RUMember ✭✭

    Finally first mattward's advice was helpful.
    Setting to v5.0 fixed issue.
    Or try to set value to certain framework version in settings.

  • @PavelIvanov that allowed installing it but when I try to build I get the following errors:

    _Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip and extract it to the C:\Users\Ertay\AppData\Local\Xamarin\Android.Support.v7.AppCompat\21.0.3\content directory.

    Reason: C:\Users\Ertay\AppData\Local\Xamarin\Android.Support.v7.AppCompat\21.0.3\android_m2repository_r10.zip is not a valid zip file

    Please install package: 'Android Support Library' available in SDK installer. Java library file C:\Users\Ertay\AppData\Local\Xamarin\Android.Support.v7.AppCompat\21.0.3\embedded\classes.jar doesn't exist.

    Unzipping failed. Please download https://dl-ssl.google.com/android/repository/android_m2repository_r10.zip and extract it to the C:\Users\Ertay\AppData\Local\Xamarin\Android.Support.v7.AppCompat\21.0.3\content directory.

    Reason: C:\Users\Ertay\AppData\Local\Xamarin\Android.Support.v7.AppCompat\21.0.3\android_m2repository_r10.zip is not a valid zip file

    Please install package: 'Android Support Library' available in SDK installer. Android resource directory C:\Users\Ertay\AppData\Local\Xamarin\Android.Support.v7.AppCompat\21.0.3\embedded./ doesn't exist.

    This is very frustrating.

  • Apparently my .zip file was corrupted. But just replacing it didn't fix the issue, VS started freezing during the build process and java.exe spiked to 100% cpu usage. To fix this, I updated from JDK 1.7 to JDK 1.8 (x64).

  • PaulPPaulP USMember ✭✭

    Setting the TargetFrameworkVersion worked for me. Steps :

    1. Unload Android Project
    2. Edit .csproject
    3. Add %Whatever version you want to target%
      Example : v4.1
    4. Reload project
    5. Re-add nuget package
  • Chris.3704Chris.3704 USUniversity ✭✭
    edited March 2015

    Hi,

    the suggestion worked for me:
    I edited the .proj file for Android and changed this line to the target API version in the AndroidManifest.xml:
    <TargetFrameworkVersion>*your value here*</TargetFrameworkVersion>

    To this line:
    <TargetFrameworkVersion>v4.0.3</TargetFrameworkVersion>

  • AlecTucker.2208AlecTucker.2208 AUInsider, University, Developer Group Leader mod

    Downloading the zip to where the error message said fixed this for me

  • WilliamSRodzWilliamSRodz BRInsider, University, Developer Group Leader ✭✭

    Like @PavelIvanov said, the solution presented by @mattward was helpful to resolve this issue \o/

  • PaulP steps helped - mine is working now.

  • yash777yash777 INMember ✭✭
    edited September 2015

    the path to zip is showing wrong to me when I try build using jenkins + msbuild -
    "C:\windows\system32\config\systemprofile\AppData\Local\Xamarin\Android.Support.v4\22.2.1"
    where as its actually in "C:\Users\Username\AppData\Local\Xamarin\Android.Support.v4\22.2.1"

    From where I can change this path ?? Do anyone have any Idea...

Sign In or Register to comment.