error in strings.xml in doing widget #<drawable /> - android

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Widget_demo</string>
<string name="action_settings">Settings</string>
<drawable />
</resources>
Here I am getting the following error in line <drawable />:
error: A 'name' attribute is required for `<drawable>`

Change
<string name="app_name">Widget_demo</string>
<string name="action_settings">Settings</string>
<drawable /> // remove this
to
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Widget_demo</string>
<string name="action_settings">Settings</string>
</resources>
Also go through the docs
http://developer.android.com/guide/topics/resources/string-resource.html

remove following:
<drawable />

Related

Issue extracting resource from Android values.xml file

I have an Android app I am trying to build, and I am getting the following error:
Apparently it was unable to compile the values resource file.
I have followed some of the suggestions in this StackOverflow question. I've gone through my strings.xml file and put a backslash before characters like the colon, the exclamation point, the full stop etc. I have looked at the colours and they do appear to be correct:
I have rebuilt several times, and done several cleans. I even restarted Android studio after putting the backslash into my strings.xml. I have tried looking in logs, but I cannot see where the issue is. Is there anything else I need to check?
Contents of resource files are below:
colours.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#c86f22</color>
<color name="BackgroundAccent">#ff424242</color>
</resources>
dimens.xml:
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="appbar_padding_top">8dp</dimen>
</resources>
font_certs.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="com_google_android_gms_fonts_certs">
<item>#array/com_google_android_gms_fonts_certs_dev</item>
<item>#array/com_google_android_gms_fonts_certs_prod</item>
</array>
<string-array name="com_google_android_gms_fonts_certs_dev">
<item>
MIIEqDCCA5CgAwIBAgIJANWFuGx90071MA0GCSqGSIb3DQEBBAUAMIGUMQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bn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kyugwfYwXFU1+5fZKUaRKYCwkkFQVfcAs1fXA5V+++FGfvjJ/CxURaSxaBvGdGDhfXE28LWuT9ozCl5xw4Yq5OGazvV24mZVSoOO0yZ31j7kYvtwYK6NeADwbSxDdJEqO4k//0zOHKrUiGYXtqw/A0LFFtqoZKFjnkCAQOjgdkwgdYwHQYDVR0OBBYEFMd9jMIhF1Ylmn/Tgt9r45jk14alMIGmBgNVHSMEgZ4wgZuAFMd9jMIhF1Ylmn/Tgt9r45jk14aloXikdjB0MQswCQYDVQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTEWMBQGA1UEBxMNTW91bnRhaW4gVmlldzEUMBIGA1UEChMLR29vZ2xlIEluYy4xEDAOBgNVBAsTB0FuZHJvaWQxEDAOBgNVBAMTB0FuZHJvaWSCCQDC4IdGZEowjTAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4IBAQBt0lLO74UwLDYKqs6Tm8/yzKkEu116FmH4rkaymUIE0P9KaMftGlMexFlaYjzmB2OxZyl6euNXEsQH8gjwyxCUKRJNexBiGcCEyj6z+a1fuHHvkiaai+KL8W1EyNmgjmyy8AW7P+LLlkR+ho5zEHatRbM/YAnqGcFh5iZBqpknHf1SKMXFh4dd239FJ1jWYfbMDMy3NS5CTMQ2XFI1MvcyUTdZPErjQfTbQe3aDQsQcafEQPD+nqActifKZ0Np0IS9L9kR/wbNvyz6ENwPiTrjV2KRkEjH78ZMcUQXg0L3BYHJ3lc69Vs5Ddf9uUGGMYldX3WfMBEmh/9iFBDAaTCK
</item>
</string-array>
</resources>
ic_launcher_background.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="ic_launcher_background">#808080</color>
</resources>
ids.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="CardTicket" type="id">0000001</item>
<item name="tempCard" type="id">0000002</item>
</resources>
preloaded_fonts.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<array name="preloaded_fonts" translatable="false">
<item>#font/advent_pro_medium</item>
</array>
</resources>
strings.xml:
<resources>
<string name="app_name">FixITApp</string>
<!-- Strings related to login -->
<string name="prompt_email">Email</string>
<string name="prompt_password">Password (optional)</string>
<string name="action_sign_in">Sign in or register</string>
<string name="action_register">Register</string>
<string name="back">Back</string>
<string name="Sign_in_here">Already have an account\? Sign in here\:</string>
<string name="Register_here">No Account\? Register here for your free account\!</string>
<string name="ExitToMenu">Exit to Main Menu</string>
<string name="Exit_App">Exit Application</string>
<string name="action_sign_in_short">Sign in</string>
<string name="error_invalid_email">This email address is invalid</string>
<string name="error_invalid_password">This password is too short</string>
<string name="error_incorrect_password">This password is incorrect</string>
<string name="error_field_required">This field is required</string>
<string name="permission_rationale">"Contacts permissions are needed for providing email
completions\."
</string>
<string-array name="IssueTypes">
<item> </item>
<item>Please Select a value\:</item>
<item>PC</item>
<item>Server</item>
<item>Laptop</item>
<item>Monitor</item>
<item>Keyboard</item>
<item>Mouse</item>
<item>RAM</item>
<item>HardDrive</item>
<item>Projector</item>
<item>Interactive Board</item>
<item>Other</item>
</string-array>
<string-array name="Severities">
<item> </item>
<item>Please Select a value\:</item>
<item>Critical</item>
<item>High</item>
<item>Moderate</item>
<item>Low</item>
</string-array>
</resources>
styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.PopUpTing">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowCloseOnTouchOutside">true</item>
</style>
</resources>
OK, so I got it working.
The problem was in ids.xml, which contained the following:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="CardTicket" type="id">0000001</item>
<item name="tempCard" type="id">0000002</item>
</resources>
I ran the build again using --scan, and learnt that <item> inner element must either be a resource reference or empty. I removed the 0000001 and 000002 from the IDs and it is now building.

Ripple colour has already been defined Android

I am trying to import a library in Android:
compile 'com.materialcontentoverflow:materialcontentoverflow:1.1.0'
But when I try it tells me that:
C:\Users\A\Desktop\Project\app\build\intermediates\exploded-aar\me.drakeet.materialdialog\library\1.2.2\res\values\values.xml
But if I look in that project there is no values with rippleColor. This is the file:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- From: file:/Users/drakeet/AndroidStudioProjects/MaterialDialog/library/src/main/res/values/color.xml -->
<eat-comment/>
<color name="card_background">#ffffff</color>
<color name="card_shadow">#10000000</color>
<color name="lite_blue">#ff359ff2</color>
<color name="window_background">#00000000</color>
<!-- From: file:/Users/drakeet/AndroidStudioProjects/MaterialDialog/library/src/main/res/values/dimens.xml -->
<eat-comment/>
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<!-- From: file:/Users/drakeet/AndroidStudioProjects/MaterialDialog/library/src/main/res/values/strings.xml -->
<eat-comment/>
<string name="action_settings">Settings</string>
<string name="app_name">MaterialDialog</string>
<string name="hello_world">Hello world!</string>
The library that I am trying to import has the following as values.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- From: file:/home/artur/workspaceAndroidStudio/MaterialContentOverflow/materialcontentoverflow/src/main/res/values/colors.xml -->
<eat-comment/>
<color name="shadow_end_color">#android:color/transparent</color>
<color name="shadow_mid_color">#14000000</color>
<color name="shadow_start_color">#44000000</color>
<declare-styleable name="FloatingActionButton"><attr name="android:background"/><attr name="backgroundTint"/><attr name="backgroundTintMode"/><attr format="color|reference" name="rippleColor"/><attr name="fabSize"><enum name="normal" value="0"/><enum name="mini" value="1"/></attr><attr name="elevation"/><attr format="dimension|reference" name="pressedTranslationZ"/></declare-styleable>
<declare-styleable name="MaterialContentOverflow"><attr format="reference" name="buttonDrawable"/><attr format="reference" name="fabButtonColor"/><attr format="reference" name="contentColor"/><attr format="enum" name="buttonPosition"><enum name="left" value="0"/><enum name="center" value="1"/><enum name="right" value="2"/></attr></declare-styleable>
<!-- From: file:/home/artur/workspaceAndroidStudio/MaterialContentOverflow/materialcontentoverflow/src/main/res/values/dimens.xml -->
<eat-comment/>
<dimen name="fab_content_size">24dp</dimen>
<dimen name="fab_elevation">8dp</dimen>
<dimen name="fab_size_mini">40dp</dimen>
<dimen name="fab_size_normal">56dp</dimen>
<dimen name="fab_translation_z_pressed">6dp</dimen>
I can't work out what the problem is?! Can anyone help please?
Checking the source on github
<!-- Ripple color for the FAB. -->
<attr name="rippleColor" format="color|reference" />
This library is using the rippleColor.
You can't use it since it is used by supportlibrary.
You can clone the library changing the attr.

Top level element is not completed and Valid XML must have a root tag : Android Studio

I am getting an error at android:title="#string/action_refresh" and android:title="#string/action_settings" stating Top level element is not completed and Valid XML must have a root tag. What must I do to correct this error?
Ffragment.xml:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:id="#+id/action_refresh"
android:title="#string/action_refresh"
app:showAsAction="never" />
</menu>
my.xml:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context=".MyActivity" >
<item android:id="#+id/action_settings"
android:title="#string/action_settings"
android:orderInCategory="100"
app:showAsAction="never" />
</menu>
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">My Application</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="action_refresh">Refresh</string>
</resources>
In this other question, it is stated that you simply surround with <root> </root> your XML.

Error when add <declare-styleable> tag in Android

Please help me, error at declare-styleable tag: No found tag
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<declare-styleable name=”Gallery1”>
<attr name=”android:galleryItemBackground” />
</declare-styleable>
</resources>
You are using ” instead of ". Try the following:
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<declare-styleable name="Gallery1">
<attr name="android:galleryItemBackground" />
</declare-styleable>
</resources>

Why aren't the colours in my res file being recognised?

I'm getting this error in my code:
Error: No resource found that matches the given name (at 'background' with value #color/red').
Here is my TextView:
<TextView
android:id="#+id/tv01"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/prizeFund"
android:background="#color/red">
</TextView>
And the color definition, in colors.xml in res/values:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#ff0000</color>
<color name="green">#00ff00</color>
<color name="blue">#0000ff</color>
</resources>
Try to clean your project The R.java file will be regenerated for you
On eclipse go to Project---->Clean..
also the resources must be in strings.xml not colors.xml
below an exemple of the strings.xml file
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Strings Resources -->
<string name="animations">Animations: </string>
<string name="compass">Compass: </string>
<!-- Colors Resources -->
<color name="opaque_white">#FFFFFFFF</color>
<color name="gray">#FF888888</color>
</resources>

Categories

Resources