Visual Studio 2017编译Xamarin.Forms安卓应用报错求助
Hey there, let's tackle this ResolveSdks task failure in your Xamarin.Forms Android project—since iOS builds fine, the issue is almost certainly tied to Android SDK/tooling configuration. Here are the most reliable fixes that usually resolve this error:
Verify Android SDK Path & Version Consistency
- Open your IDE's SDK Manager: For Visual Studio (Windows), go to
Tools > Android > Android SDK Manager; for Visual Studio for Mac, useTools > SDK Manager. - Confirm the Android SDK Build Tools version matches what your project targets. Right-click your Android project >
Properties > Android Manifestto check the Target Android Version, then ensure that exact version's Build Tools, Platform Tools, and SDK Platform are installed in the SDK Manager (no missing or corrupted components). - Double-check system environment variables
ANDROID_HOMEorANDROID_SDK_ROOTpoint to the correct SDK directory—typos or wrong paths here often trigger this error.
- Open your IDE's SDK Manager: For Visual Studio (Windows), go to
Clean & Rebuild the Project Thoroughly
- Start with cleaning the entire solution:
Build > Clean Solution - Manually delete the
binandobjfolders from your Android project directory (this clears cached build artifacts that might be corrupted) - Rebuild the solution:
Build > Rebuild Solution - Cached SDK references are a common culprit here, so a full clean/rebuild often refreshes dependencies correctly.
- Start with cleaning the entire solution:
Update Xamarin & Android Tooling
- Outdated Xamarin components can clash with newer Android SDK versions. For Visual Studio (Windows), go to
Extensions > Manage Extensionsand check for updates to Xamarin.Android and related plugins. - On Visual Studio for Mac, use
Visual Studio > Check for Updatesto install the latest stable versions of all Xamarin and Android tools.
- Outdated Xamarin components can clash with newer Android SDK versions. For Visual Studio (Windows), go to
Validate Project File Configuration (Advanced)
- Right-click your Android project >
Edit Project Fileto open the.csprojfile. Look for the<AndroidSdkBuildToolsVersion>node—ensure its value matches the Build Tools version you have installed (e.g.,<AndroidSdkBuildToolsVersion>34.0.0</AndroidSdkBuildToolsVersion>). If the node is missing, add it manually. - Also confirm the
<TargetFrameworkVersion>corresponds to an installed Android SDK version (e.g.,<TargetFrameworkVersion>v13.0</TargetFrameworkVersion>).
- Right-click your Android project >
Repair Corrupted Android SDK Files
- If all components appear installed but the error persists, uninstall the problematic Build Tools/Platform Tools in the SDK Manager, then reinstall them.
- You can also try deleting the
.androidcache folder (Windows:C:\Users\<YourUsername>\.android; Mac:~/.android) to clear corrupted cache data, then restart your IDE.
If none of these steps work, try creating a blank new Xamarin.Forms project and building its Android target. If the new project builds successfully, the issue is likely in your original project's configuration—you can gradually migrate code and resources to the new project to isolate the problem.
内容的提问来源于stack exchange,提问作者Kannan

