I want to learn MAUI and build an Android app. I only plan to target Android at the moment. I've created a project from Visual Studio templates and I got the multi-platform code and the Platforms directory with platform-specific code. This platform-specific code makes it much less readable in my opinion. How can I set the project to only target Android and remove this paltform-specific code?
Asked
Active
Viewed 149 times
0
-
What platform-specific code are you talking about that "makes it much less readable"? What exactly are you struggling with? MAUI is a cross-platform technology, but you can also simply ignore (or even remove) the other platforms and only develop the app for Android. You don't even need to do Android-specific things, just write the shared code and deploy to Android only. – Julian Jul 05 '23 at 09:31
-
A cross-platform solution can't cover every possible detail of every platform. Android-specific code is known as ".Net Android" (previously called "Xamarin.Android"; that's what you'll see in most online references). Cross-platform code and Android code are kept separate, because they have access to different libraries (APIs). If you don't want this, then consider project template `Android Application`: *"A project for creating a .Net Android application"*. This would not be Maui; it would use Android APIs for UI, just like java/kotlin. – ToolmakerSteve Jul 05 '23 at 18:26
1 Answers
1
When creating a .NET MAUI project by template there is no platform specific app-code. Inside the Platforms directory you will only find what would be necessary to build and run your App on those platforms. For you that is Android and everything to make that work is already there. Right now you have no reason to change anything here OR to delete any file unrelated to android.
Same goes for the <TargetFrameworks/>
inside the .csproj File as shown by the stackoverflow question linked by Martheen. But I also wouldn't recommend that as for now you are only trying things out and having to revert those changes later would be double the work.

OZOBPIR
- 56
- 3
-
2*"Same goes for the
"*: Its easy enough to UNCHECK those platforms in your project properties. This may speed up compilation slightly. CHECK them again later if needed. – ToolmakerSteve Jul 05 '23 at 18:28