I am working on converting a Xamarin.Android
app to .NET for Android.
I have created an entirely new Solution
& Project
in Visual Studio 2022 & I used the Android Application
Project Template. Visual Studio 2022 creates the following file:
_Microsoft.Android.Resource.Designer.cs
This file contains the Resource
class defined as follows:
public partial class Resource : _Microsoft.Android.Resource.Designer.ResourceConstant{}
As you can see, this class is completely empty (it does not contain any of the constants for the Resource
s in my Project
). The declaration is declared as partial
, so I don't know if there is some other file that is also generated, but Visual Studio 2022 claims that Resource
does not have definitions for Layout
, Style
, Id
, etc. Sometimes (although I don't know what things are causing it) the Resource
s are regenerated, but once I do anything like Rebuild or close & reopen Visual Studio 2022, they get removed and then it takes a long time before it decides to regenerate them (whatever it is that causes it). I looked at the following page:
https://devblogs.microsoft.com/dotnet/android-resource-designer-dotnet-8/
But it still doesn't give a way to regenerate the Resource
s. What is the problem? How can I force Visual Studio 2022 to regenerate the Resource
s in .NET for Android?
@Nathan Sokalski, you sure are running into problems. I presume you're trying to create a net8.0-android app. Have you successfully built/deployed and run the standard app built from the template Android Application? The main point of the standard app is that it shows you how the new proj files are created.
If you did that successfully, what were your next steps in bringing in your code, especially your resources? The easiest way to do it before you add any code is to delete the contents of each resource folder. Folder by folder, and then use add existing item, getting the items from your existing project folder into the same folder name in the new app. That way, you should be able to build the app without error.
If you need a new folder, create it first and then do the same thing.
Build it after adding all the contents of one of your resource folders, one at a time. If you get an error, it should be obvious what went wrong.
There are faster ways of doing it, but doing it one folder at a time is the safest way when doing it for the first time.
What version of VS are you using? - the latest is 17.11.5
Have you followed the instructions for dotnet workload install android.
See the readme and the links in NavigationGraph8Net8
If your existing app is a multi-activity app, just forget it. Learn how to use the NavigationComponent before you even attempt to move it to .net.