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

VS2017 15.5.5配置Xamarin Android4.1项目遇错误求解决方案

Hey there, let's work through this step by step to get your Xamarin Android project running smoothly for Android 4.1+ on VS2017 15.5.5. Here's a straightforward configuration plan tailored to your situation:

Step 1: Clean Up Your Project Environment First

Start with a fresh slate to eliminate cached issues:

  • Right-click your solution → Select Clean Solution
  • Manually delete the bin and obj folders from your Android project directory (these hold compiled artifacts that often cause conflicts)
  • Restart Visual Studio to clear any in-memory cache
Step 2: Adjust Project Framework Settings (Critical Fix)

The mistake here was lowering the target framework to Android 4.1—modern support libraries don't work with such old frameworks. Instead:

  1. Right-click your Android project → Open Properties
  2. Go to the Application tab:
    • Minimum Android version: Set to Android 4.1 (API Level 16) (this covers your required compatibility)
    • Target framework: Choose Android 8.1 (API Level 27) (this is a stable version that works well with VS2017 15.5.5 and maintains backward compatibility with 4.1)
    • Target Android version: Select "Use compile using Android version (API 27)" (matches your target framework)
Step 3: Fix NuGet Package Compatibility Issues

The Xamarin.Android.Support.Design package error comes from mismatched or outdated support library versions. Here's how to fix it:

  1. Open NuGet Package Manager (right-click project → Manage NuGet Packages)
  2. Go to the Installed tab, uninstall all Xamarin.Android.Support.* packages (including Design, Library, AppCompat, etc.)
  3. Switch to the Browse tab, search for Xamarin.Android.Support.Library and install version 27.0.2.1 (this version is fully compatible with VS2017 15.5.5 and API 27)
    • Ensure all support packages you install are the same version—never mix different versions
  4. If you still see NU1202 errors, open the NuGet Package Console and run:
    Update-Package -reinstall
    
    This forces a fresh install of all packages with correct dependencies.
Step 4: Restore Missing Resources & Styles

You deleted some critical files earlier—let's bring back the basics without extra bloat:

  1. Create a new Toolbar.axml file in Resources/layout with this default content:
    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
    
  2. Ensure Resources/values/styles.xml has a basic AppCompat theme:
    <resources>
        <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
            <item name="colorPrimary">@color/colorPrimary</item>
            <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
            <item name="colorAccent">@color/colorAccent</item>
        </style>
    </resources>
    
  3. Check that Resources/values/colors.xml exists with defined color values (e.g., <color name="colorPrimary">#3F51B5</color>) to avoid "resource not found" errors.
Step 5: Verify Compilation & Deployment
  • Right-click your solution → Select Rebuild Solution
  • If you still see resource identifier errors, double-check all layout files for typos in control IDs, then run Clean Solution again before rebuilding.

This setup keeps your project compatible with Android 4.1+ while using a modern enough framework to support necessary libraries, eliminating the compatibility and resource errors you're facing.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.15 06:30:33