Bug 656002 - ApplicationAttribute Not Generating in Manifest
Summary: ApplicationAttribute Not Generating in Manifest
Status: RESOLVED WONTFIX
Alias: None
Product: MonoDroid
Classification: Novell Products
Component: Tools (show other bugs)
Version: unspecified
Hardware: x86-64 Windows 7
: P5 - None : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-25 17:31 UTC by Adam Tybor
Modified: 2010-11-27 13:55 UTC (History)
0 users

See Also:
Found By: Beta-Customer
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.