Has anyone see this issue, know if its a new bug, or if it's something in my system's cache? I appreciate any assistance as this is a show-stopper for our project.
Android.Content.Res.Resources+NotFoundException: 'String resource ID #0x7f0c0001'
Shortly after upgrading from VS v16.7.2 to v16.7.5 I started to get the error in my Android project's OnCreate
method in the base.OnCreate(bundle)
. The odd thing is, the Pull Request for this branch doesn't show any resource changes in the Android project.
Just to prove it was not the new branch, I created a new folder using the develop
branch and I get the same error after just a few rebuilds which did not happen before.
I've tried the following which worked for a little bit, and now it throws the error every time.
obj
and bin
folders and rebuild (with VS restart)git clean -fxd
(with VS closed)The Resource ID 0x7F0C0001
points to:
// aapt resource value: 0x7F0D0001 public const int abc_action_bar_up_description = 2131558401;
I performed a file search for the const associated with the hex-value. The const has different values being generated across each of the files in the obj
folder.
Why would this happen?
Resource.Designer.cs
in \droid\Resources is different than the obj
folder.R.java
- Same value in some filesR.txt
- Different value in all of themMicrosoft Visual Studio Enterprise 2019 v16.7.5 VisualStudio.16.Release/16.7.5+30523.141 Microsoft .NET Framework Version 4.8.03752 Mono Debugging for Visual Studio 16.7.5 (112c7bc) Support for debugging Mono processes with Visual Studio. Xamarin 16.7.000.452 ([email protected]) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android. Xamarin Designer 16.7.0.495 (remotes/origin/[email protected]) Visual Studio extension to enable Xamarin Designer tools in Visual Studio. Xamarin Templates 16.7.85 (1bcbbdf) Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms. Xamarin.Android SDK 11.0.2.0 (d16-7/025fde9) Xamarin.Android Reference Assemblies and MSBuild support. Mono: 83105ba Java.Interop: xamarin/java.interop/[email protected] ProGuard: Guardsquare/proguard/[email protected] SQLite: xamarin/sqlite/[email protected] Xamarin.Android Tools: xamarin/xamarin-android-tools/[email protected]
The issue was solved using the undesirable destructive method where no lessons were learned
Steps:
1. Uninstall Visual Studio 2019 (Enterprise)
2. Performed the Remove Visual Studio procedure
3. Removed all NuGet packages via, nuget locals all -Clear
* Clearing NuGet HTTP cache: %UserProfile%\AppData\Local\NuGet\v3-cache * Clearing NuGet global packages folder: %UserProfile%\.nuget\packages\ * Clearing NuGet Temp cache: %UserProfile%\AppData\Local\Temp\NuGetScratch * Clearing NuGet plugins cache: %UserProfile%\AppData\Local\NuGet\plugins-cache
* %UserProfile%\AppData\Local\Xamarin\ * %UserProfile%\AppData\Local\Xamarin.Android\
Although I am unhappy that nothing was learned about the root-cause, I am happy that is this project can continue again until the next time.
Thank you @Irongut for assisting in the troubleshooting process. That was a huge help! Your next beer is on me if we ever meet at a convention.
Answers
This is quite odd. I noticed there was an update in Android SDK Manager for Android 9.0 to spring my Platform 28 up from v5 to v6 and Platform 29 from v4 to v5. After upgrading and rebuilding, the project launched -
Resource.Designer.cs
has the value as0x7F0D0001
in both the project andobj
folders.Unfortunately, after a couple of cleans and rebuilds with no code changes. It reverts back to
0x7f0c0001
in the project and gets out of sync with theResource.Designer.cs
in theobj
folder and fails to run.Can someone help point me to anything as to why this is being generated like so?
Reading over @JonathanPeppers article, Faster Xamarin.Android Builds & Smaller Dex Files for any insights to how these are generated.
Though the issue remains, I tested with my 2nd older laptop where it does not have the issue. Keep in mind, this older laptop isn't sticking around much longer - therefore I'm not switching to this one.
On the 2nd dev device, I am unable to reproduce the issue using VS 2019 Enterprise v16.7.3 (not v16.7.5 above). This leads to conclude, there is either something wrong with the caching or the upgraded system introduces the issue.
AppData - Something Odd
Searching for
abc_action_bar_up_description
in the AppData folder uncovered something different in theR.txt
files. Only the Xamarin.Android.Support.v7.MediaRouter folder had theR.txt
with the conflicting value.0x7f050003
0x7f050003
0x7f060003
Question:
Any thoughts as to why these values are different and why Xamarin.Android throws a conflict?
Projects Generated Files
The
obj\Debug\100
folder does not have conflicting values forR.txt
and theResource.Designer.cs
files.Generated R.txt
Generated Resource.Designer.cs
Laptop-2 Version
@JamesMontemagno do you have any advice on what information I should collect before creating a new bug for Xamarin.Android?
Currently,
abc_action_bar_up_description
appears to have different values for its constants which is causing run-time failures at the line,base.OnCreate(bundle);
@DamianSuess Did you find a solution to this issue? I'm having a similar problem with a different resource id.
Android.Content.Res.Resources+NotFoundException Message=String resource ID #0x7f0c0003
Are you using AndroidX packages by chance? Been hoping for someone from Xamarin to assist in troubleshooting
Yes, I'm using AndroidX and like yourself the app with the issue is at a standstill. Fortunately it is just an experimental app, not a released product but I was hoping to use it for testing Xamarin 5.0 which is not possible while I can't debug.
I found time to compare the problem app with one of my other apps that uses the exact same AndroidX packages, it has no problems.
My apps use GitHub Actions to keep dependencies up to date and run builds + unit tests. So I compared the list of Nugets between the two apps and downgraded the packages that were only in the problem app to versions that were available the last time I built and tested manually. This eventually pinpointed the problem package - Microcharts. Not a great surprise, the new maintainer of that library breaks something with every release.
@DamianSuess I suggest you try something similar, downgrade any libraries you're not sure about to an earlier version and hopefully you'll find the one causing you problems too.
@Irongut, which version of AndroidX did you end up downgrading to? Definitely would like to give it a try.
Thanks for the heads up on the Microcharts; I was using
MoneyFox.Microcharts.Forms
. Unfortunately, even after removing that dependency & switching to a custom CircleProgress bar, I'm still getting that dreaded error. Also removed,Xamarin.Forms.Visual.Material
w/ a Clean > closed VS > deletedobj
&Resource.Designer.cs
.Can you think of any tree to shake from the official Xamarin team who may have some insight into this?
Dumping my latest exception if this assists anyone reading this
The issue was solved using the undesirable destructive method where no lessons were learned
Steps:
1. Uninstall Visual Studio 2019 (Enterprise)
2. Performed the Remove Visual Studio procedure
3. Removed all NuGet packages via,
nuget locals all -Clear
Although I am unhappy that nothing was learned about the root-cause, I am happy that is this project can continue again until the next time.
Thank you @Irongut for assisting in the troubleshooting process. That was a huge help! Your next beer is on me if we ever meet at a convention.