Bug 656002

Summary: ApplicationAttribute Not Generating in Manifest
Product: [Novell Products] MonoDroid Reporter: Adam Tybor <adam.tybor>
Component: ToolsAssignee: Mono Bugs <mono-bugs>
Status: RESOLVED WONTFIX QA Contact: Mono Bugs <mono-bugs>
Severity: Normal    
Priority: P5 - None    
Version: unspecified   
Target Milestone: ---   
Hardware: x86-64   
OS: Windows 7   
Whiteboard:
Found By: Beta-Customer Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Adam Tybor 2010-11-25 17:31:11 UTC
Description of Problem: 
On Preview 8.1, when trying to use the ApplicationAttribute either as an assembly level attribute or on an Application subclass, the resulting attribute properties are not added to the AndroidManifest.xml


Steps to reproduce the problem:
1. Create new MonoDroid application
2. Create a new application subclass

[Application(Label="@string/app_name"
    , Description = "@string/app_description"
    , Theme = "@android:style/Theme.Light.NoTitleBar"
    , Debuggable = true, AllowClearUserData = true)]
public class MyApp : Application
{
  public MyApp(IntPtr handle) : base(handle)
  {
  }
}

4. Build the application
5. Look at the final merged androidmanifest.xml

Actual Results:
The following is the in the androidmanifest.xml

<application android:label="@string/app_name">
...
</application>

Expected Results:
<application 
  android:name=".MyApp"
  android:label="@string/app_name"
  android:description="@string/app_description"
  android:theme="@android:style/Theme.Light.NoTitleBar"
  android:debuggable="true">
...
</applicatin>


How often does this happen? 
All the time

Additional Information:
I have tried both as an assembly level attribute and an attribute on the application class and neither seem to work.
Comment 1 Adam Tybor 2010-11-26 04:04:47 UTC
Looks like the issue is that if the applicationattribute exists in code the additional attributes will not be merged with an existing <application></application> element specified within the Properties\AndroidManifest.xml

Once I removed that application element, the application element was properly generated in the final manifest file.

Is this the desired implementation?

Shouldn't the properties on the applicationattribute just be merged / overwritten on any existing <application></application> element within the manifest?

If I need any customizations within my Manifest I need an <application> element thus eliminating the ability to specify the attribute in code.
Comment 2 Jon Pryor 2010-11-27 13:55:38 UTC
This is desired behavior.  There's no reasonable way for monodroid to know which parts of AndroidManifest.xml to keep vs. overwrite from the code, so the current "priority" order is:

  1. monodroid command-line args (e.g. --application)
  2. Template AndroidManifest.xml contents
  3. Source code attributes

For example, what if we changed your example so that MyApp [Application] attribute used "@string/app_name2" instead of "@string/app_name" for ApplicationAttribute.Label?  Which should be used, the [Application] value or the AndroidManifest.xml value?  As per the above priority list, we use the AndroidManifest.xml value.

> If I need any customizations within my Manifest I need an <application> element
> thus eliminating the ability to specify the attribute in code.

Exactly; if attributes are not flexible enough for your needs, then simply use the XML directly.

You might also consider filing bugs so we can add additional attributes to remove the need to modify the XML directly.