I have a .NET 9 MAUI project, targeting Android devices only, built with Visual Studio 2022 17.13.5.
After adding a reference to a third-party DLL, I cannot compile in Debug configuration because of this error:
Errore (attivo) XAAMM0000 C:\myProject\obj\Debug\net9.0-android35.0\AndroidManifest.xml:14:225-250 Error:
Attribute application@debuggable value=(true) from AndroidManifest.xml:14:225-250
is also present at AndroidManifest.xml:15:9-35 value=(false).
Suggestion: add 'tools:replace="android:debuggable"' to <application> element at AndroidManifest.xml:14:3-31:17 to override. myProject (net9.0-android35.0) C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.39\tools\Xamarin.Android.Common.targets 1561
Following the suggestion, I added the ,android:debuggable
attribute to my AndroidManifest.xml
manifest and the projects compiles.
The situation in Release mode is the opposite: I cannot compile the project if I leave there the attribute, but it compiles if I remove it.
Errore (attivo) AMM0000
tools:replace specified at line:14 for attribute android:debuggable, but no new value specified
C:\repos\myProject\myProject\obj\Release\net9.0-android35.0\AndroidManifest.xml
Error:
Validation failed, exiting myProject (net9.0-android35.0) C:\repos\myProject\myProject\obj\Release\net9.0-android35.0\AndroidManifest.xml 14
Errore (attivo) XAAMM0000 C:\repos\myProject\myProject\obj\Release\net9.0-android35.0\AndroidManifest.xml:14:3-31:17
Error:
tools:replace specified at line:14 for attribute android:debuggable, but no new value specified
C:\repos\myProject\myProject\obj\Release\net9.0-android35.0\AndroidManifest.xml
Error:
Validation failed, exiting myProject (net9.0-android35.0) C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\35.0.39\tools\Xamarin.Android.Common.targets 1561
Now, I was expecting that the debuggable attribute would have been automatically replaced based on the configuration, but this doesn't happen in Release mode.
How can I solve this? Is there a way, in Release mode, to either:
false
the ,android:debuggable
value,android:debuggable
attributeDid you check your AndroidManifest.xml? The first error means that the debuggable property has different value in AndroidManifest.xml or the other dependency' Manifest. And this made the gradle can't merge the Manifest automatically. So you can use tools:replace="android:debuggable"
to fix it.
And the second error means that when you used tools:replace="android:debuggable"
, you have to set the new value for android:debuggable
. Such as:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application android:debuggable="true" tools:replace="android:debuggable" ....