Hi @guo tuo , thank you for confirming that restoring the [Application] attribute in MainApplication.cs resolved the issue.
To provide some additional context on the solution, missing attributes may not necessarily result in an obvious build error or exception, so they can cause hard-to-trace issues and easily be overlooked during troubleshooting. Thus, checking for them could be a useful troubleshooting step.
As you found in this case, the missing attribute in Platforms/Android/MainApplication.cs was the cause. The [Application] attribute is important because it tells Android to use MainApplication when the app starts. Without it, the normal .NET MAUI initialization through MainApplication may not take place.
using Android.App;
using Android.Runtime;
namespace YourApp;
[Application]
public class MainApplication : MauiApplication
{
public MainApplication(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
For similar project-specific issues, comparing the files under Platforms/Android with those from a newly created .NET MAUI project can also help identify accidental changes or omissions.
If you found my explanation was helpful or informative to the solution, I would greatly appreciate it if you could follow this guide so others with the same issue can benefit as well. Thank you.