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

VS2019 Android项目Resources+NotFoundException异常求助

Troubleshooting Android.Resource.NotFoundException in Visual Studio 2019 (Works in VS2017)

Hey there, let’s break down this resource ID issue you’re facing—it’s super frustrating when something works in one VS version but breaks in another, especially with Xamarin Android resources. I’ve tackled similar headaches before, so let’s dive into targeted fixes beyond what you’ve already tried:

First, a quick recap to align:

  • You have a standalone Android Class Library with .axml layouts that generates Resource.Designer.cs
  • App launches smoothly in VS2017, but crashes in VS2019 with Android.Content.Res.Resources+NotFoundException: 'Resource ID #0x7f09001b'
  • You’ve already upgraded Xamarin Support Library to v28 and adjusted minSdkVersion/maxSdkVersion/targetSdkVersion without luck

1. Fix Resource.Designer.cs Generation & Sync

VS2019 changed resource generation logic compared to VS2017, so let’s ensure this file is properly synced:

  • Clean your entire solution: Go to Build > Clean Solution
  • Manually delete the bin and obj folders for both your class library and main app project (the clean command sometimes leaves leftover files)
  • Rebuild the class library first, then the main app. Open the class library’s Resource.Designer.cs and search for the hex ID 0x7f09001b—confirm it maps to an existing resource name (like a layout or drawable)
  • Double-check the file’s properties: Right-click Resource.Designer.cs > Properties > Set Copy to Output Directory to Do not copy

2. Resolve Resource Naming & Conflicts

VS2019 enforces stricter resource rules, so conflicts that flew under the radar in VS2017 might now cause crashes:

  • Make sure no resource names (layouts, drawables, strings) are duplicated across your class library and main app
  • Stick to lowercase with underscores for resource names (e.g., user_profile.axml instead of UserProfile.axml)—uppercase letters or special characters can break resource mapping
  • Use the missing ID to find the resource name in Resource.Designer.cs, then verify the corresponding file exists in the class library’s Resources folder

3. Tweak VS2019 Xamarin Android Build Settings

New build configurations in VS2019 can sometimes mess with resource packaging:

  • Open your main app’s properties > Android Options > Advanced
  • Set Android SDK Build Tools Version to match what you used in VS2017 (if you remember it) or the latest stable version compatible with v28 support libraries
  • Toggle Use incremental Android packaging system (aapt2)—sometimes enabling/disabling this fixes quirky resource packaging bugs
  • Confirm your class library is referenced as a Project Reference (not a DLL) in the main app: Right-click main app > Add > Reference > Ensure the class library is checked

4. Fix Xamarin Android Version Mismatches

VS2019 ships with newer Xamarin Android versions that might clash with your existing setup:

  • Go to Tools > Options > Xamarin > Android Settings to check your current Xamarin Android SDK version
  • If you’re on a cutting-edge version, try downgrading to the version paired with your VS2017 installation (you can grab older versions via the Visual Studio Installer)
  • Ensure both your class library and main app target the same Xamarin Android framework version

5. Explicitly Reference Class Library Resources

Sometimes the main app fails to link the class library’s resources automatically:

  • In your activity code, use the full namespace to reference the resource instead of relying on implicit linking. For example, instead of Resource.Layout.MyLayout, use YourClassLibraryNamespace.Resource.Layout.MyLayout

If none of these steps work, try creating a blank new Android app in VS2019, reference your class library, and test if the resource loads. This will help you isolate whether the issue is with your main app’s configuration or the class library itself.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.14 08:09:32