You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Xamarin.Android报错:无法找到中央目录记录结尾,求助添加指定NuGet包

Fixing "End of Central Directory record could not be found" in Xamarin.Android

Hey there, let's tackle this "End of Central Directory record could not be found" error you're hitting when adding those Google Play Services packages to your Xamarin.Android project. I’ve run into this exact issue a handful of times, so here are the practical steps I’d recommend trying to get past it:

1. Clear the Entire NuGet Cache

Corrupted NuGet cache files are the most common culprit here. Here’s how to wipe them out:

  • First, close Visual Studio entirely—this ensures no files are locked.
  • Open Command Prompt (Windows) or Terminal (macOS) and run this command to clear all NuGet local caches:
    nuget locals all -clear
    
  • Restart Visual Studio, then try restoring or reinstalling your packages again.

2. Delete Damaged Package Files

If clearing the cache doesn’t work, you might have leftover corrupted package files on your system:

  • Navigate to your project’s packages folder (usually in the solution root) and delete any folders related to the Google Play Services packages you’re adding (e.g., Xamarin.GooglePlayServices.Ads, Xamarin.GooglePlayServices.Basement).
  • Next, check your global NuGet package directory:
    • Windows: C:\Users\[YourUsername]\.nuget\packages
    • macOS: ~/.nuget/packages
      Delete the same package folders here too.
  • Try reinstalling the packages via the NuGet Package Manager or Package Manager Console.

3. Verify Package Version Compatibility

You’re targeting monoandroid80 with version 60.1142.0 of these packages—compatibility mismatches can trigger this error:

  • Open the NuGet Package Manager, search for one of the packages, and check the Dependencies tab to confirm version 60.1142.0 supports MonoAndroid 8.0.
  • If there’s a mismatch, you have two options:
    • Upgrade your project’s target framework to a newer version (like MonoAndroid 9.0 or higher) that the package supports.
    • Downgrade to an older version of the packages that explicitly lists MonoAndroid 8.0 as a supported target.

4. Repair NuGet Tooling or Visual Studio

Sometimes the issue lies with the NuGet tooling itself:

  • In Visual Studio, go to Tools > NuGet Package Manager > Package Manager Settings.
  • Under NuGet Package Manager > General, click Clear All NuGet Cache(s).
  • Check the Package Sources section to ensure the official NuGet source (https://api.nuget.org/v3/index.json) is enabled and correctly formatted.
  • If problems persist, repair your Visual Studio installation via the Visual Studio Installer (select your installation, click Modify > Repair).

5. Manual Package Installation (Last Resort)

If all else fails, you can manually add the packages:

  • Go to NuGet.org, search for each package, and download the .nupkg file for version 60.1142.0.
  • Rename the .nupkg file to .zip and extract its contents.
  • Copy the relevant assembly files into your project’s references, then set the Copy Local property to True for each reference.
  • Note: This is a workaround—you’ll lose automatic package updates, but it can get you unblocked temporarily.

Give these steps a try in order, starting with clearing the cache—it’s usually the quickest fix. Let me know if any of these resolve your issue, or if you hit other snags along the way!

内容的提问来源于stack exchange,提问作者Amit

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 07:00:55