android: .NET Maui - running basic template project has a runtime error

This issue has been moved from a ticket on Developer Community.


After some issues with an attempted Maui upgrade to an existing Xamarin project, in an attempt to understand Maui a little better I decided to just make a brand new Maui project from the basic templates that are found in Visual Studio. I chose the “.NET MAUI Multi-Project App” option, and then when asked what project types to include, chose only iOS and Android.

This template does not build successfully right out of the box, though. I’ll describe below the modifications that were made to get past the build stage of this process, in case it is relevant.

Upon creation, it loads in a solution with only one iOS project and one Android project, nothing else. If you try to build this you will get two errors saying it cannot find a dll file somewhere in a /obj folder in the main project, which is created with the template but not included in the solution when you initially start. So I added the project, built THAT, and the errors went away.

After that, I received an error stating (filepath truncated) “Assets file ‘~\MauiTestApp\MauiTestApp.iOS\obj\project.assets.json’ doesn’t have a target for ‘net8.0-ios/ios-arm64’”

After Googling for a solution to this I found a hint saying to add this to the iOS project’s csproj:

<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">
	<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
</PropertyGroup>

After adding this, it did build successfully. However, this is where I cannot progress. When I try to run the Android version in an Android emulator (Pixel 5, Android 13.0 - API 33), at runtime while the app is loading up, this occurs:

android error.PNG

Text of the error for searching purposes: Java.Lang.NoClassDefFoundError: ‘Failed resolution of: Landroidx/startup/R$string;’

I have googled for similar issues and have not had much luck in finding any clear solutions. As mentioned, the only modifications I have made are what were necessary to get it running. Can anyone give me a hint as to what I might be missing?

PC is running on Windows 10, version 10.0.19045

Visual studio information (and installed tools as that is included in the ‘About’ window): Microsoft Visual Studio Professional 2022 Version 17.11.5 VisualStudio.17.Release/17.11.5+35327.3 Microsoft .NET Framework Version 4.8.09037

Installed Version: Professional

Visual C++ 2022 00483-00100-36538-AA059 Microsoft Visual C++ 2022

ADL Tools Service Provider 1.0

ASA Service Provider 1.0

ASP.NET and Web Tools 17.11.231.19466

Azure App Service Tools v3.0.0 17.11.231.19466

Azure Data Lake Tools for Visual Studio 2.6.5000.0

Azure Functions and Web Jobs Tools 17.11.231.19466

Azure Stream Analytics Tools for Visual Studio 2.6.5000.0

C# Tools 4.11.0-3.24460.3+5649376e0e5f5db3743a94a62b073f2cce4be5d9

Common Azure Tools 1.10

Extensibility Message Bus 1.4.39 (main@e8108eb)

Microsoft Azure Hive Query Language Service 2.6.5000.0

Microsoft Azure Stream Analytics Language Service 2.6.5000.0

Microsoft JVM Debugger 1.0

Mono Debugging for Visual Studio 17.11.3 (ba13144)

NuGet Package Manager 6.11.1

Oracle Developer Tools for Visual Studio 21.11.0.0

Razor (ASP.NET Core) 17.11.3.2442001+68650a7d94261bc56a1f4bc522c2ee35314b1abb

SQL Server Data Tools 17.11.47.0

ToolWindowHostedEditor 1.0

TypeScript Tools 17.0.30715.2002

Visual Basic Tools 4.11.0-3.24460.3+5649376e0e5f5db3743a94a62b073f2cce4be5d9

Visual F# Tools 17.11.0-beta.24421.7+af2f522de602281d4ef5a7b71507c428e814c5c1

Visual Studio IntelliCode 2.2

VisualStudio.DeviceLog 1.0

VisualStudio.Mac 1.0

VSPackage Extension 1.0

Xamarin 17.11.0.98 (d17-11@86652fe)

Xamarin Designer 17.11.3.11 (remotes/origin/d17-11@cdbb0a4fdd)

Xamarin Templates 17.9.0 (38e87ba)

Xamarin.Android SDK 13.2.2.0 (d17-5/45b0e14) Xamarin.Android Reference Assemblies and MSBuild support. Mono: d9a6e87 Java.Interop: xamarin/java.interop/d17-5@149d70fe SQLite: xamarin/sqlite/3.40.1@68c69d8 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d

Xamarin.iOS and Xamarin.Mac SDK 16.4.0.23 (9defd91b3)


Original Comments

Feedback Bot on 10/17/2024, 06:16 PM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (8 by maintainers)

Most upvoted comments

I have an update - I happened to update Visual Studio 2022 to the most recent version that was just put out, and decided to run this again, and it appears to have worked. Not sure what changed but here is the new basic info in case it helps anyone:

Microsoft Visual Studio Professional 2022 Version 17.12.0 VisualStudio.17.Release/17.12.0+35506.116 Microsoft .NET Framework Version 4.8.09037

You guys can probably close this if you don’t have anything else to add. Thank you for your time!