Hi
I am facing a problem
I want my application to pick up resources from the framework. Here is my code snippet of an xml.
For this to be achieved following changes were made in attrs.xml
and themes.xml at the framework level
#android:drawable/btn_minus_ss
The drawable btn_minus_ss.png is added to drawable-hdpi folder at the location framework/base/core/res/res/drawable-hdpi
Whenever I open the application, it crashes.
I get the following error in logs
ERROR/AndroidRuntime(3701): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #5: tag requires a 'drawable' attribute or child tag defining a drawable
However, when I use this
android:background="?android:attr/theme_btn_minus_ss"
I don't get any error. I want to use
android:drawable
What is the cause and how can this problem be solved.
Thanks & Regards
Aviral
The error
ERROR/AndroidRuntime(3701): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #5: tag requires a 'drawable' attribute or child tag defining a drawable
has to do with the format of your xml, you are setting something like
<item android:background="#foo-value-here" />
What the error is telling you is that it should be like this
<item android:drawable="#foo-value-here" />
i think i had the same problem, it seems to be a bug in the android eclipse-plugin. the solution is the same as for this question (close eclipse and restart it): android include tag - invalid layout reference
Also make android:drawable the first attribute of item tag - it worked for me.
Related
I found this error on my crashlytics and i don't know what the problem is.
So by just looking to the code i thought it could be something with one of the images.
So by researching i realized it could be one of these two things: I put the image in drawable-24 and it should be in drawable folder. So i checked and all the images are in the drawable folder. Then i thought it could be because i should use app:srcCompat instead of android:src. The problem is if i changed the gradle file to use this, it would affect the entire module and i would get the error : When using VectorDrawableCompat, you need to use app:srcCompat.
I've made some custom icons in inkscape, saved as svg and transform the svg to the vector drawable. The drawable i saved under the drawable-v21 folder. After this i add the new vector to the navigation drawer menu. After this i open the layout which include the menu and i see my custom icon, everything fine.
But if i start the app i get a android.view.InflateException: Binary XML file line #16: Error inflating class android.support.design.widget.NavigationView and if i looking through the exception i see at the end a Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f02004d.
I have no idea why, because i see the icon in the layout preview.
Any ideas?
What i have done: gradle sync, invalidate and restart android studio.
Thank's in advance.
It's running on version 19
Since you are putting your drawable in drawable-v21 folder it means it is intended for API 21 and up, as as you are running on API 19 there's no drawable available, hence the Exception. So you must either provide alternative drawable for other APIs or do not access this drawable when app is running on pre 21 API
mandatory read - docs on providing resources.
For those they running in the same problem, you must search for a file calling drawables.xml in this file android define the fallback/alternative image. It look's like this:
<item name="custom_image_xml" type="drawable">#drawable/custom_image</item>
and in the navigationdrawer menu:
<item
android:id="#+id/nav_overview"
android:icon="#drawable/custom_image_xml"
android:title="#string/action.overview" />
Note: That's "_xml" suffix is only used to explain and illustrate the mapping in the drawables.xml
I try to refer to ?attr/actionBarSize in dimens.xml in two ways:
<dimen name="bottom_margin">?attr/actionBarSize</dimen>
<dimen name="bottom_margin">#attr/actionBarSize</dimen>
The first one is compiling but I get runtime error from inflanter:
RuntimeException: Unable to resume activity {pl.example/pl.example.ui.gui.MainActivity}: android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>
So question is: how to refer to that value?
Next I will use this value in animator or use from code.
Actually I don't see if there is a sense to declare own dimensions if it already declared in theme, so it would be better to use ?attr/actionBarSize directly where you need that.
But if you really need it for some reason try as following:
<dimen name="bottom_margin">?actionBarSize</dimen>
The correct syntax is:
?android:attr/actionBarSize
Use it like this with android key.
android:layout_width="?android:actionBarSize"
I am Developing an Android Application, by default it is running in English properly then i Translate it in to Welsh and Urdu by translate String file into corresponding language and placed it into values-cy and values-ur.When i run it show error message like
' 02-09 05:07:35.083: ERROR/AndroidRuntime(584): Caused by: java.lang.RuntimeException: Binary XML file line #11:'
You must supply a layout_width attribute..I studied that particular xml but it didn't noticed any problem in that line but it worked in engish properly(I used Styles/String and Theme in my resource).After that i create a new xml file with only one Textview here i gave all styles within that Tag..
.Now i locked with this problem.So please help me to solve this problem.
I think you are using custom theme. If so,call styles from theme. May be it will work.
Try it.. Happy coding :)
I got an error error: Error parsing XML: unbound prefix when i did not add an attribute xmlns:android="http://schemas.android.com/apk/res/android" for my Layout. Why we want to set this attribute for a layout?Any Specific Reasons? what i put the url mentioned as a value for xmlns:android. I got the server not found Exception. Please Share your knowledge about this?
This is not really an attribute for your layout but the namespace for the XML. Adding this xmlns:android would allow you to use all the "android:..." attributes and others.
WRT the 'server not found' exception, can you post the XML file ?
Matthieu explained why you need that attribute.
The reason you're getting a server not found error, is because XML namespace URLs aren't required to actually exist, and in this case they clearly don't.