I'm getting this error in my project, and I cannot for the life of me find where my navigationMode is getting defined twice.
Error:(707) Attribute "navigationMode" already defined with incompatible format.
The source of the error is this file:
/Users/temp/code/MyCoolProject/app/build/intermediates/res/merged/debug/values/values.xml
How is this file generated? I didn't write it.
Here it is defined in my:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="navigationMode">
<enum name="listMode" value="1" />
<enum name="normal" value="0" />
<enum name="tabMode" value="2" />
</attr>
</resources>
How can I get rid of this error?
Check your operations with action bar.
Related
First of all, i know that there plenty of post about the issue and i think i read them all. If someone ask i will attach them for approve :)
I have an issue with attrs. The issue is that sometimes i see programmers using it when they create a custom view but sometimes i see that they are used also when building a theme.
For example:
<declare-styleable name="Main_Theme">
<attr name="background" format="reference" />
<attr name="backgroundCard" format="reference" />
<attr name="secondaryTextColor" format="reference" />
<attr name="primaryTextColor" format="reference" />
<attr name="primaryColor" format="reference" />
<attr name="secondaryColor1" format="reference" />
<attr name="secondaryColor2" format="reference" />
<attr name="secondaryColor3" format="reference" />
<attr name="dividerColor" format="reference" />
and then they creates a theme using it.
For example:
<item name="background">#color/dark_theme_background</item>
<item name="backgroundCard">#color/dark_theme_card_background</item>
<item name="secondaryTextColor">#color/dark_theme_scores_new</item>
<item name="primaryTextColor">#color/dark_theme_primary_text_color</item>
<item name="primaryColor">#color/dark_theme_primary_color</item>
<item name="secondaryColor1">#color/dark_theme_secondary_1_color</item>
<item name="secondaryColor2">#color/dark_theme_secondary_2_color</item>
<item name="secondaryColor3">#color/dark_theme_secondary_3_color</item>
<item name="dividerColor">#color/dark_theme_divider_color</item>
Then i saw them using those items as values for attributes in layout activity xml file
So i really can't understand the variety use of attrs.
I hope someone can help me to understand cause i feeling very confused
attr is used when make custom view with custom attribute.
If you define attr, you can use it in xml file.
Normal View use default attribute such as width, height, background, text etc.
So you can use it in xml file.
<TextView
android:width="match_parent"
android:height="wrap_content"
android:background="#color/white"
android:text="#string/app_name" />
But there is no attribute for your custom view.
If your custom view needs dividerColor attribute, you can't use it android:dividerColor as following.
<YourCustomView
android:width="match_parent"
android:height="wrap_content"
android:background="#color/white"
android:dividerColor="#color/black" /> // it caused compile error.
So you need your attribute for use in xml file.
For it, you need declare attrs in attrs.xml file. (xml file name can change.)
<declare-styleable name="Main_Theme">
<attr name="dividerColor" format="reference" />
</declare-styleable>
And then you can use new attribute in view xml file.
<YourCustomView
xmlns:app="http://schemas.android.com/apk/res-auto" // need define app
android:width="match_parent"
android:height="wrap_content"
android:background="#color/white"
app:dividerColor="#color/black" /> // it's works
PS: You need to additional code for use custom attr in YourCustomView class file.
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.Main_Theme);
dividerColor = ta.getColor(R.styleable.MainTheme_divider_color, Color.WHITE);
Attr represents an attribute in an element. Simply put attrs are allowable quantities that are defined in a schema associated with a document.
Whenever we create a custom view we don't want the view to accept every possible value under the sky, so we define a few values that can be accepted by the view using the attr interface. these attributes are defined using declare-stylable that enables you to define attributes for custom views.for example:
<resources>
<declare-styleable name="PieChart">
<attr name="showText" format="boolean" />
<attr name="labelPosition" format="enum">
<enum name="left" value="0"/>
<enum name="right" value="1"/>
</attr>
</declare-styleable>
</resources>
this custom view accepts showText and label attributes. the showText accepts a boolean value and the labelPosition accepts values: left and right. like the example below
<PieChart
showText="false"
labelPosition="left"/>
similarly in themes we need to define certain attributes that can be used inside the theme for example if we create 2 themes and want to define a different primary color that will be used by the app when using either theme. we first declare the color attr like so in the attrs.xml:
<declare-styleable name="Main_Theme">
<attr name="color_primary" format="color" />
</declare-stylable>
and then inside the styles.xml we define the values for the color_primary attr for the 2 themes
<style name="theme_one">
<item name="color_primary">#ff0000</item> // red
</style>
<style name="theme_two">
<item name="color_primary">#00ff00</item> // green
</style>
this value could then be used in layout files like so: ?attr/color_primary
similarly attr could be used to define a wide range of things. an attr element itself has 2 attributes the name with which you refer it in other parts of the code and the format which could be color, boolean, dimension, float etc. for example enums could be defined as:
<attr name="some_enum_attr">
<enum name="value_one" value="1" />
<enum name="value_two" value="2" />
</attr>
I am using custom font style for that created custom xml attributes.already used enum in declared style attributes but still no success. Its seems some messed up and facing the below-mentioned issue.
Facing this issue:
Error:(555, 5) error: expected enum but got (raw string) bold.
attrs.xml file is
<declare-styleable name="CustomTextView">
<attr name="font_name" format="string" />
<attr name="font_style" format="enum">
<enum name="normal" value="0" />
<enum name="bold" value="1" />
<enum name="italic" value="2" />
</attr>
</declare-styleable>
I created styles for Textview.
<style name="STextView">
<item name="android:textColor">#color/colorBlack</item>
<item name="font_style">bold</item>
</style>
It was working earlier recently updated compile sdk version in build.gradle to 27 and stated facing this issue.
Change
<item name="font_style">bold</item>
to
<item name="font_style">#bold</item>
I want to generate a MSI package which contains only one feature.
I have a wxi file which is generated automatically. I cannot change this process.
wxi file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<Include>
<!-- components -->
<Feature Id="DefaultFeature" Title="Main Feature" Level="1">
<ComponentRef Id="comp0" />
<ComponentRef Id="comp1" />
<ComponentRef Id="comp2" />
<ComponentRef Id="comp3" />
<ComponentRef Id="CleanupMainApplicationFolder" />
</Feature>
</Include>
I have a wxs file which I can change:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product ...>
<!-- components -->
<?include bundle.wxi ?>
<UI/>
<FeatureRef Id="DefaultFeature">
<ComponentRef Id="comp999" />
</FeatureRef>
</Product>
</Wix>
When I compile the wxs to MSI package Light is stating this error:
error LGHT0095 : Multiple primary references were found for Feature 'DefaultFeature' in Product '{...}' and Product '{...}'.
How do I change my wxs file to add a component to the feature defined in wxi file?
Thanks in advance.
Use <ComponentGroup> in your include files instead of <Feature>. Then, define your features in one place, the main .wxs file with <Product> element.
For example, this is how include file might look:
<Fragment>
<Component Id="Comp1" Guid="{GUID-GOES-HERE}">
...
</Component>
<Component Id="Comp2" Guid="{GUID-GOES-HERE}">
...
</Component>
<Component Id="Comp3" Guid="{GUID-GOES-HERE}">
...
</Component>
<ComponentGroup Id="CG1">
<ComponentRef Id="Comp1"/>
<ComponentRef Id="Comp2"/>
<ComponentRef Id="Comp3"/>
</ComponentGroup>
</Fragment>
And the main product.wxs defines the feature, includes the component group in there and allows including more components:
<Feature Id="MainFeature" Title="..." Level="100">
<ComponentGroupRef Id="CG1"/>
<!-- More components can go here -->
<Component Id="..">
</Component>
</Feature>
Moreover, you can include wxs files instead of include, too. As long as the main wxs references at least one element from another wxs, the entire contents will be included.
I have a xml file "versionreferance.xml". below is the coding
<?xml version="1.0" encoding="utf-8"?>
<!-- Update "revision" value to -1 when the next build is intended to have its revision as 0. This needs to be done for patch/release builds-->
<BuildVersions>
<property name="major" value="1" />
<property name="minor" value="0" />
<property name="patch" value="0" />
<property name="revision" value="93" />
</BuildVersions>
The other is my ant-build.xml file.
<?xml version="1.0" encoding="UTF-8"?>
<project name="xmlproperty-demo" default="init">
<xmlproperty file="versionreferance.xml" collapseAttributes="true" />
<echo>Major : ${BuildVersions.major}</echo>
<echo>Minor : ${BuildVersions.minor}</echo>
<echo>Patch : ${BuildVersions.patch}</echo>
<echo>Revision : ${BuildVersions.revision}</echo>
</project>
I am not getting the value in the output.
I want to get the path path dynamically of versionReference.xml , which will be in different place than antbuild.xml
Development\Build\VersionReference.xml
Development\Src\JAAS API\antbuild.xml
It should be dynamically. I am able to get the values form below code. But it's not dynamic.
<?xml version="1.0" encoding="UTF-8"?>
<project name="xmlproperty-demo" default="init">
<xmlproperty file="C:\\Development\\Build\\versionreferance.xml" collapseAttributes="true" />
<echo>Major : ${BuildVersions.major}</echo>
<echo>Minor : ${BuildVersions.minor}</echo>
<echo>Patch : ${BuildVersions.patch}</echo>
<echo>Revision : ${BuildVersions.revision}</echo>
</project>
I want to get the values only in this format.
<?xml version="1.0" encoding="utf-8"?>
<!-- Update "revision" value to -1 when the next build is intended to have its revision as 0. This needs to be done for patch/release builds-->
<BuildVersions>
<property name="major" value="1" />
<property name="minor" value="0" />
<property name="patch" value="0" />
<property name="revision" value="93" />
</BuildVersions>
I highly recommend using the free, third-party XmlTask library:
build.xml
<taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" />
<xmltask>
<fileset file="versionreferance.xml"/>
<copy path="/BuildVersions/property[#name = 'major']/#value" property="BuildVersions.major"/>
<copy path="/BuildVersions/property[#name = 'minor']/#value" property="BuildVersions.minor"/>
<copy path="/BuildVersions/property[#name = 'patch']/#value" property="BuildVersions.patch"/>
<copy path="/BuildVersions/property[#name = 'revision']/#value" property="BuildVersions.revision"/>
</xmltask>
<echo>Major : ${BuildVersions.major}</echo>
<echo>Minor : ${BuildVersions.minor}</echo>
<echo>Patch : ${BuildVersions.patch}</echo>
<echo>Revision : ${BuildVersions.revision}</echo>
Output
run:
[echo] Major : 1
[echo] Minor : 0
[echo] Patch : 0
[echo] Revision : 93
If you add <echoproperties/> after the <xmlproperty> line you should see the properties are loaded but not as you expect. They will be something like:
BuildVersions.property=,,,
BuildVersions.property.name=major,minor,patch,revision
BuildVersions.property.value=1,0,0,93
This is because the properties are based off the node names, and in your case you have four instances of a "property" child node that are not unique. Your best bet may be to change the xml such as:
<BuildVersions>
<major>1</major>
....
</BuildVersions>
When you say xmlproperty with collapseAttributes="true" on xml file, it will flatten nested elements.
Details: https://ant.apache.org/manual/Tasks/xmlproperty.html
So just saying ${BuildVersions.major} doesn't give or print value as 1. Since you have same named xml element 'prooerty' you won't be able to get single propertie's value
For eg, in your case ${BuildVersions.property.name} will print 'major,minor,patch,revision'
Either you can redesign your versionreferance.xml to respect xmlproperty to work . Or you can make it as property file & say <property file="your.properties.file"/> & access them as normal properties!
If VersionReference.xml is going to be exactly where you mentioned in your question corresponding to your antbuild.xml.
I would suggest you to change your Absolute Path (as mentioned in question) with "..\..\Build\VersionReference.xml" which corresponds to the basedir="." in your project
This should work fine.
And considering your string format requirement.
I think the default comma(,) seperated value can then be replaced by dot(.) or manipulated as per your requirement by the following syntax
<propertyregex property="propB"
input="${propA}"
regexp=","
replace="."
global="true" />
Please find more info on this link :
Replacing characters in Ant property
Hope this helps.
I was creating custom content model
in datalistModel.xml
<type name="dl:car">
<title>Car List</title>
<parent>dl:dataListItem</parent>
<properties>
<property name="dl:carName">
<title>Car Name</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
<property name="dl:carCompany">
<title>Company Name</title>
<type>d:text</type>
<mandatory>false</mandatory>
</property>
</properties>
</type>
in share-datalist-form-config.xml
<!-- dl:contact type create car form -->
<config evaluator="model-type" condition="dl:car">
<forms>
<!-- Create item form -->
<form>
<field-visibility>
<!-- dl:contact type -->
<show id="dl:carName" />
<show id="dl:carCompany" />
</field-visibility>
<create-form template="../data-lists/forms/dataitem.ftl" />
</form>
</forms>
</config>
When I create a new car content in repository browser(I later configured menu to add content type 'Car'), the file name is 91b65385-86c6-4923-859d-6ecb3326319c.
<create-content>
<content id="plain-text" mimetype="text/plain" label="create-content.text" itemid="cm:content" icon="text"/>
<content id="html" mimetype="text/html" label="create-content.html" itemid="cm:content"/>
<content id="xml" mimetype="text/xml" label="create-content.xml" itemid="cm:content"/>
<content id="car" mimetype="text/xml" icon="xml" label="create-content.car" itemid="dl:car"/>
</create-content>
How can I make the file name to carName instead of 91b65385-86c6-4923-859d-6ecb3326319c
Any kind help is appreciated.
Take a look at the default 'share-datalist-form-config.xml'
You will see that almost every type specify <show id="cm:title" />
You could also just put <show id="name" /> or <show id="cm:name" /> to show the name attribute.
In order to put the title you will need to put the cm:titled aspect in your model.
Just check the 'datalistModel.xml' how the defaults are defined
And check this blog post to know a bit more how to create custom datalists.